Skip to contentSkip to conversation

Doamin crash when trying to install disk encryption (PointSec) on Windows HVM

DISCUSSION Tom Rotenberg 3 participants 43 messages Apr 22, 2009 – Apr 26, 2009

lore
Share & tools
lore
#0 lore raw

Hi all,

i am trying to install the disk encryption software: 'PointSec', on a Windows HVM. After the product is installed, in my second reboot, when the PointSec is trying to load is UI, the domain is crashing, with the following error:

(XEN) HVM2: Booting from Hard Disk...
(XEN) HVM2: Booting from 0000:7c00
(XEN) realmode.c:115:d2 Failed to emulate insn.
(XEN) realmode.c:165:d2 Real-mode emulation failed @ 1eae:00000787: 0f 00 d0 e4 70 0c
(XEN) domain_crash called from realmode.c:166
(XEN) Domain 2 (vcpu#0) crashed on cpu#0:
(XEN) ----[ Xen-3.4.0-rc3-pre x86_64 debug=n Not tainted ]----
(XEN) CPU: 0
(XEN) RIP: 1eae:[<0000000000000787>]
(XEN) RFLAGS: 0000000000004046 CONTEXT: hvm guest

(XEN) rax: 0000000000000000   rbx: 0000000000000007   rcx: 0000000000100000
(XEN) rdx: 0000000000000000   rsi: 0000000000000000   rdi: 0000000000000000
(XEN) rbp: 0000000000008ebf   rsp: 0000000000017a5e   r8:  0000000000000000
(XEN) r9:  0000000000000000   r10: 0000000000000000   r11: 0000000000000000
(XEN) r12: 0000000000000000   r13: 0000000000000000   r14: 0000000000000000
(XEN) r15: 0000000000000000   cr0: 0000000000000011   cr4: 0000000000000000
(XEN) cr3: 0000000000000000   cr2: 0000000000000000

(XEN) ds: 0040 es: 0080 fs: 0040 gs: 0040 ss: 2112 cs: 1eae

To me, it looks like the xen real-mode emulator fails to emulate the "LLDT" instruction.
I disassembled the code (as reported from the real-mode error message), and it looks like this:
LLDT AX
IN AL, 70
OR AL, 8B

AFAIK, the PointSec is trying to load his UI (which is probably coded in realmode) in this stage, and i guess that some of the instrctions he uses aren't emulated in Xen.

I am using xen-unstable, changeset: 19553 (from April 16), and the machione i am working on, is a Lenovo T500.

Can someone please help me with this, as i am not really familiar with the real mode emulation code?

Thanks,
Tom

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw
Quoted 9 lines · Tom Rotenberg

AFAIK, the PointSec is trying to load his UI (which is probably coded in realmode) in this stage, and i guess that some of the instrctions he uses aren't emulated in Xen.

I am using xen-unstable, changeset: 19553 (from April 16), and the machione i am working on, is a Lenovo T500.

Can someone please help me with this, as i am not really familiar with the real mode emulation code?

We don't emulate LLDT at the moment. Try the attached patch.

-- Keir

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#2 lore raw

Keir,

I have applied your patch, and it seemed to work. However, the domain still crashes, and now it looks like it's because of the 'LTR' instruction.

The (new) error i am receiving is:

(XEN) HVM1: Booting from Hard Disk...
(XEN) HVM1: Booting from 0000:7c00
(XEN) realmode.c:115:d1 Failed to emulate insn.
(XEN) realmode.c:165:d1 Real-mode emulation failed @ 1eae:00000797: 0f 00 d8 66 b8 8e
(XEN) domain_crash called from realmode.c:166
(XEN) Domain 1 (vcpu#0) crashed on cpu#0:
(XEN) ----[ Xen-3.4.0-rc3-pre x86_64 debug=n Not tainted ]----
(XEN) CPU: 0
(XEN) RIP: 1eae:[<0000000000000797>]
(XEN) RFLAGS: 0000000000004086 CONTEXT: hvm guest

(XEN) rax: 0000000000000050   rbx: 0000000000000007   rcx: 0000000000100000
(XEN) rdx: 0000000000000000   rsi: 0000000000000000   rdi: 0000000000000000
(XEN) rbp: 0000000000008ebf   rsp: 0000000000017a5e   r8:  0000000000000000
(XEN) r9:  0000000000000000   r10: 0000000000000000   r11: 0000000000000000
(XEN) r12: 0000000000000000   r13: 0000000000000000   r14: 0000000000000000
(XEN) r15: 0000000000000000   cr0: 0000000000000011   cr4: 0000000000000000
(XEN) cr3: 0000000000000000   cr2: 0000000000000000

(XEN) ds: 0068 es: 0068 fs: 0068 gs: 0068 ss: 0070 cs: 1eae

Tom

2009/4/22 Keir Fraser <[email protected]>

Quoted 10 lines · Tom Rotenberg
Quoted 6 lines

AFAIK, the PointSec is trying to load his UI (which is probably coded in realmode) in this stage, and i guess that some of the instrctions he uses aren't emulated in Xen.

I am using xen-unstable, changeset: 19553 (from April 16), and the

machione i

Quoted 2 lines

am working on, is a Lenovo T500.

Quoted 9 lines
Quoted 1 line

Can someone please help me with this, as i am not really familiar with

the

Quoted 1 line

real mode emulation code?

We don't emulate LLDT at the moment. Try the attached patch.

-- Keir

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#3 lore raw
Quoted 4 lines · Tom Rotenberg

Keir,

I have applied your patch, and it seemed to work. However, the domain still crashes, and now it looks like it's because of the 'LTR' instruction.

Try the attached patch. It replaces the one I sent last time, and emulates both LLDT and LTR.

-- Keir

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#4 lore raw

Keir,

I have tried your latest patch, and it looks like now it passes the emulation problem. However, now the domain crashes with the following error:

(XEN) HVM1: Booting from 0000:7c00
(XEN) Failed vm entry (exit reason 0x80000021) caused by invalid guest state (0).
(XEN) ************* VMCS Area **************
(XEN) *** Guest State ***
(XEN) CR0: actual=0x0000000080010039, shadow=0x0000000080000019, gh_mask=ffffffffffffffff
(XEN) CR4: actual=0x0000000000002060, shadow=0x0000000000000000, gh_mask=ffffffffffffffff
(XEN) CR3: actual=0x000000000a213a20, target_count=0
(XEN) target0=0000000000000000, target1=0000000000000000
(XEN) target2=0000000000000000, target3=0000000000000000
(XEN) RSP = 0x0000000000000080 (0x0000000000000080) RIP = 0x000000000000002a (0x000000000000002a)
(XEN) RFLAGS=0x0000000000023202 (0x0000000000023202) DR7 = 0x0000000000000400
(XEN) Sysenter RSP=0000000000000000 CS:RIP=0000:0000000000000000 (XEN) CS: sel=0x0060, attr=0x0c09b, limit=0xffffffff, base=0x0000000000200000
(XEN) DS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) SS: sel=0x0070, attr=0x0c093, limit=0xfc000fff, base=0x000000000020ba62
(XEN) ES: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) FS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) GS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) GDTR: limit=0x00001dd8,
base=0x0000000000200000
(XEN) LDTR: sel=0x0000, attr=0x1c000, limit=0xffffffff, base=0x0000000000000000
(XEN) IDTR: limit=0x00000188,
base=0x0000000000201df0
(XEN) TR: sel=0x0058, attr=0x0008b, limit=0x0000ffff, base=0x0000000000201ff2
(XEN) Guest PAT = 0x0000000000000000
(XEN) TSC Offset = ffffffe4920110b7
(XEN) DebugCtl=0000000000000000 DebugExceptions=0000000000000000 (XEN) Interruptibility=0001 ActivityState=0000
(XEN) *** Host State ***
(XEN) RSP = 0xffff83007e4f7fa0 RIP = 0xffff828c8019aa20
(XEN) CS=e008 DS=0000 ES=0000 FS=0000 GS=0000 SS=0000 TR=e040 (XEN) FSBase=0000000000000000 GSBase=0000000000000000 TRBase=ffff828c802a8b00
(XEN) GDTBase=ffff83007e9a3000 IDTBase=ffff83007e62e010
(XEN) CR0=0000000080050033 CR3=000000007cfdc000 CR4=00000000000026f0 (XEN) Sysenter RSP=ffff83007e4f7fd0 CS:RIP=e008:ffff828c801c7290 (XEN) Host PAT = 0x0000000000000000
(XEN) *** Control State ***
(XEN) PinBased=0000003f CPUBased=b6a1e7fe SecondaryExec=00000041 (XEN) EntryControls=000011ff ExitControls=0003efff
(XEN) ExceptionBitmap=00044080
(XEN) VMEntry: intr_info=80000b0b errcode=00001eac ilen=00000000 (XEN) VMExit: intr_info=00000000 errcode=00008000 ilen=00000000
(XEN) reason=80000021 qualification=00000000
(XEN) IDTVectoring: info=00000000 errcode=00000000
(XEN) TPR Threshold = 0x00
(XEN) EPT pointer = 0x0000000000000000
(XEN) Virtual processor ID = 0x0000
(XEN) **************************************
(XEN) domain_crash called from vmx.c:2218
(XEN) Domain 1 (vcpu#0) crashed on cpu#1:
(XEN) ----[ Xen-3.4.0-rc3-pre x86_64 debug=n Not tainted ]----
(XEN) CPU: 1
(XEN) RIP: 0060:[<000000000000002a>]
(XEN) RFLAGS: 0000000000023202 CONTEXT: hvm guest

(XEN) rax: 0000000000000007   rbx: 0000000000001490   rcx: 0000000000000000
(XEN) rdx: 0000000000001da8   rsi: 0000000000000000   rdi: 0000000000000000
(XEN) rbp: 0000000000008ebf   rsp: 0000000000000080   r8:  0000000000000000
(XEN) r9:  0000000000000000   r10: 0000000000000000   r11: 0000000000000000
(XEN) r12: 0000000000000000   r13: 0000000000000000   r14: 0000000000000000
(XEN) r15: 0000000000000000   cr0: 0000000080000019   cr4: 0000000000000000
(XEN) cr3: 0000000001443000   cr2: 0000000000000000

(XEN) ds: 0068 es: 0068 fs: 0068 gs: 0068 ss: 0070 cs: 0060

Could it be, that the real mode emulation code has a bug? What does this error means?

Tom

2009/4/22 Keir Fraser <[email protected]>

Quoted 14 lines · Tom Rotenberg
Quoted 4 lines

Keir,

I have applied your patch, and it seemed to work. However, the domain

still

Quoted 1 line

crashes, and now it looks like it's because of the 'LTR' instruction.

Try the attached patch. It replaces the one I sent last time, and emulates both LLDT and LTR.

-- Keir

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#5 lore raw
Quoted 2 lines · Tom Rotenberg

Could it be, that the real mode emulation code has a bug? What does this error means?

It means we tried to enter VMX mode for the guest, and the processor did some guest state checks (listed in the x86 reference manual vol 3B, section 22.3.1). The TR and LDT state looks okay, so I don¹t think

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#6 lore raw
Quoted 8 lines · Keir Fraser
Quoted 2 lines · Tom Rotenberg

Could it be, that the real mode emulation code has a bug? What does this error means?

It means we tried to enter VMX mode for the guest, and the processor did some guest state checks (listed in the x86 reference manual vol 3B, section 22.3.1). The TR and LDT state looks okay, so I don¹t think

..oops, sent too soon...

The TR and LDT state looks okay, so I don't think the LLDT/LTR emulation is wrong, or if they are then it's in a subtle way. Probably step one would be to go through the state listed in the crash dump and compare it with the checks listed in the reference manual vol 3B. Then try to work out how the part that is wrong got to be that way. Can be a bit of a pain. :-(

I will check in the LLDT/LTR emulation code after 3.4 branches, at least.

-- Keir

#7 lore raw
In reply to Tom Rotenberg
Quoted 4 lines · Tom Rotenberg

Keir,

I have tried your latest patch, and it looks like now it passes the emulation problem. However, now the domain crashes with the following error:

Quoted 11 lines

(XEN) HVM1: Booting from 0000:7c00
(XEN) Failed vm entry (exit reason 0x80000021) caused by invalid guest state (0). (XEN) ************* VMCS Area **************
(XEN) *** Guest State ***
(XEN) CR0: actual=0x0000000080010039, shadow=0x0000000080000019, gh_mask=ffffffffffffffff (XEN) CR4: actual=0x0000000000002060, shadow=0x0000000000000000, gh_mask=ffffffffffffffff (XEN) CR3: actual=0x000000000a213a20, target_count=0
(XEN) target0=0000000000000000, target1=0000000000000000
(XEN) target2=0000000000000000, target3=0000000000000000
(XEN) RSP = 0x0000000000000080 (0x0000000000000080) RIP = 0x000000000000002a (0x000000000000002a) (XEN) RFLAGS=0x0000000000023202 (0x0000000000023202) DR7 = 0x0000000000000400

Looks like we're trying to VMENTER in virtual 8086 mode but without tidying up the segment state. That could either be the guest entering virtual 8086 mode itself or Xen entering vitrual 8086 mode to emulate real mode, but Xen is always careful to make the segment state agree with Intel's rather strict requrements when it does that.

Tim.

Quoted 59 lines

(XEN) Sysenter RSP=0000000000000000 CS:RIP=0000:0000000000000000 (XEN) CS: sel=0x0060, attr=0x0c09b, limit=0xffffffff, base=0x0000000000200000 (XEN) DS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000 (XEN) SS: sel=0x0070, attr=0x0c093, limit=0xfc000fff, base=0x000000000020ba62 (XEN) ES: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000 (XEN) FS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000 (XEN) GS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) GDTR: limit=0x00001dd8, base=0x0000000000200000
(XEN) LDTR: sel=0x0000, attr=0x1c000, limit=0xffffffff, base=0x0000000000000000
(XEN) IDTR: limit=0x00000188, base=0x0000000000201df0
(XEN) TR: sel=0x0058, attr=0x0008b, limit=0x0000ffff, base=0x0000000000201ff2 (XEN) Guest PAT = 0x0000000000000000
(XEN) TSC Offset = ffffffe4920110b7
(XEN) DebugCtl=0000000000000000 DebugExceptions=0000000000000000 (XEN) Interruptibility=0001 ActivityState=0000
(XEN) *** Host State ***
(XEN) RSP = 0xffff83007e4f7fa0 RIP = 0xffff828c8019aa20
(XEN) CS=e008 DS=0000 ES=0000 FS=0000 GS=0000 SS=0000 TR=e040 (XEN) FSBase=0000000000000000 GSBase=0000000000000000 TRBase=ffff828c802a8b00 (XEN) GDTBase=ffff83007e9a3000 IDTBase=ffff83007e62e010
(XEN) CR0=0000000080050033 CR3=000000007cfdc000 CR4=00000000000026f0 (XEN) Sysenter RSP=ffff83007e4f7fd0 CS:RIP=e008:ffff828c801c7290 (XEN) Host PAT = 0x0000000000000000
(XEN) *** Control State ***
(XEN) PinBased=0000003f CPUBased=b6a1e7fe SecondaryExec=00000041 (XEN) EntryControls=000011ff ExitControls=0003efff
(XEN) ExceptionBitmap=00044080
(XEN) VMEntry: intr_info=80000b0b errcode=00001eac ilen=00000000 (XEN) VMExit: intr_info=00000000 errcode=00008000 ilen=00000000
(XEN) reason=80000021 qualification=00000000
(XEN) IDTVectoring: info=00000000 errcode=00000000
(XEN) TPR Threshold = 0x00
(XEN) EPT pointer = 0x0000000000000000
(XEN) Virtual processor ID = 0x0000
(XEN) **************************************
(XEN) domain_crash called from vmx.c:2218
(XEN) Domain 1 (vcpu#0) crashed on cpu#1:
(XEN) ----[ Xen-3.4.0-rc3-pre x86_64 debug=n Not tainted ]----
(XEN) CPU: 1
(XEN) RIP: 0060:[<000000000000002a>]
(XEN) RFLAGS: 0000000000023202 CONTEXT: hvm guest

(XEN) rax: 0000000000000007   rbx: 0000000000001490   rcx: 0000000000000000
(XEN) rdx: 0000000000001da8   rsi: 0000000000000000   rdi: 0000000000000000
(XEN) rbp: 0000000000008ebf   rsp: 0000000000000080   r8:  0000000000000000
(XEN) r9:  0000000000000000   r10: 0000000000000000   r11: 0000000000000000
(XEN) r12: 0000000000000000   r13: 0000000000000000   r14: 0000000000000000
(XEN) r15: 0000000000000000   cr0: 0000000080000019   cr4: 0000000000000000
(XEN) cr3: 0000000001443000   cr2: 0000000000000000

(XEN) ds: 0068 es: 0068 fs: 0068 gs: 0068 ss: 0070 cs: 0060

Could it be, that the real mode emulation code has a bug? What does this error means?

Tom

2009/4/22 Keir Fraser <[email protected]<mailto:[email protected]>>

Quoted 2 lines · On 22/04/2009 12:18, "Tom Rotenberg" <[email protected]<mailto:tom.rotenb…

Keir,

Quoted 8 lines
Quoted 2 lines

I have applied your patch, and it seemed to work. However, the domain still crashes, and now it looks like it's because of the 'LTR' instruction.

Try the attached patch. It replaces the one I sent last time, and emulates both LLDT and LTR.

-- Keir

Content-Description: ATT00001.txt

Quoted 4 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

Signature · 3 lines
Tim Deegan <[email protected]>
Principal Software Engineer, Citrix Systems (R&D) Ltd.
[Company #02300071, SL9 0DZ, UK.]
#8 lore raw

Tim,

so what does it mean? could it be that we have a bug in the real mode emulation, which causes the segment state to be invalid (maybe it's because of a bug in the patch that Keir made for me, which emulated the LLDT, and the LTR instructions)?

Keir suggested to trace back where the problem (segment state) occured, and from there to try and find the bug which caused it. Do u have any better suggestion for solving this?

Tom

2009/4/22 Tim Deegan <[email protected]>

Quoted 130 lines
Quoted 3 lines · Tom Rotenberg

Keir,

I have tried your latest patch, and it looks like now it passes the

emulation problem. However, now the domain crashes with the following error:

Quoted 3 lines

(XEN) HVM1: Booting from 0000:7c00
(XEN) Failed vm entry (exit reason 0x80000021) caused by invalid guest

state (0).

Quoted 3 lines

(XEN) ************* VMCS Area **************
(XEN) *** Guest State ***
(XEN) CR0: actual=0x0000000080010039, shadow=0x0000000080000019,

gh_mask=ffffffffffffffff

Quoted 1 line

(XEN) CR4: actual=0x0000000000002060, shadow=0x0000000000000000,

gh_mask=ffffffffffffffff

Quoted 4 lines

(XEN) CR3: actual=0x000000000a213a20, target_count=0
(XEN) target0=0000000000000000, target1=0000000000000000
(XEN) target2=0000000000000000, target3=0000000000000000
(XEN) RSP = 0x0000000000000080 (0x0000000000000080) RIP =

0x000000000000002a (0x000000000000002a)

Quoted 1 line

(XEN) RFLAGS=0x0000000000023202 (0x0000000000023202) DR7 =

0x0000000000000400

Looks like we're trying to VMENTER in virtual 8086 mode but without tidying up the segment state. That could either be the guest entering virtual 8086 mode itself or Xen entering vitrual 8086 mode to emulate real mode, but Xen is always careful to make the segment state agree with Intel's rather strict requrements when it does that.

Tim.

Quoted 2 lines

(XEN) Sysenter RSP=0000000000000000 CS:RIP=0000:0000000000000000 (XEN) CS: sel=0x0060, attr=0x0c09b, limit=0xffffffff,

base=0x0000000000200000

Quoted 1 line

(XEN) DS: sel=0x0068, attr=0x0c093, limit=0xffffffff,

base=0x0000000000200000

Quoted 1 line

(XEN) SS: sel=0x0070, attr=0x0c093, limit=0xfc000fff,

base=0x000000000020ba62

Quoted 1 line

(XEN) ES: sel=0x0068, attr=0x0c093, limit=0xffffffff,

base=0x0000000000200000

Quoted 1 line

(XEN) FS: sel=0x0068, attr=0x0c093, limit=0xffffffff,

base=0x0000000000200000

Quoted 1 line

(XEN) GS: sel=0x0068, attr=0x0c093, limit=0xffffffff,

base=0x0000000000200000

Quoted 1 line

(XEN) GDTR: limit=0x00001dd8,

base=0x0000000000200000

Quoted 1 line

(XEN) LDTR: sel=0x0000, attr=0x1c000, limit=0xffffffff,

base=0x0000000000000000

Quoted 1 line

(XEN) IDTR: limit=0x00000188,

base=0x0000000000201df0

Quoted 1 line

(XEN) TR: sel=0x0058, attr=0x0008b, limit=0x0000ffff,

base=0x0000000000201ff2

Quoted 8 lines

(XEN) Guest PAT = 0x0000000000000000
(XEN) TSC Offset = ffffffe4920110b7
(XEN) DebugCtl=0000000000000000 DebugExceptions=0000000000000000 (XEN) Interruptibility=0001 ActivityState=0000
(XEN) *** Host State ***
(XEN) RSP = 0xffff83007e4f7fa0 RIP = 0xffff828c8019aa20 (XEN) CS=e008 DS=0000 ES=0000 FS=0000 GS=0000 SS=0000 TR=e040 (XEN) FSBase=0000000000000000 GSBase=0000000000000000

TRBase=ffff828c802a8b00

Quoted 15 lines

(XEN) GDTBase=ffff83007e9a3000 IDTBase=ffff83007e62e010 (XEN) CR0=0000000080050033 CR3=000000007cfdc000 CR4=00000000000026f0 (XEN) Sysenter RSP=ffff83007e4f7fd0 CS:RIP=e008:ffff828c801c7290 (XEN) Host PAT = 0x0000000000000000
(XEN) *** Control State ***
(XEN) PinBased=0000003f CPUBased=b6a1e7fe SecondaryExec=00000041 (XEN) EntryControls=000011ff ExitControls=0003efff
(XEN) ExceptionBitmap=00044080
(XEN) VMEntry: intr_info=80000b0b errcode=00001eac ilen=00000000 (XEN) VMExit: intr_info=00000000 errcode=00008000 ilen=00000000
(XEN) reason=80000021 qualification=00000000
(XEN) IDTVectoring: info=00000000 errcode=00000000
(XEN) TPR Threshold = 0x00
(XEN) EPT pointer = 0x0000000000000000
(XEN) Virtual processor ID = 0x0000

Quoted 8 lines

(XEN) **************************************
(XEN) domain_crash called from vmx.c:2218
(XEN) Domain 1 (vcpu#0) crashed on cpu#1:
(XEN) ----[ Xen-3.4.0-rc3-pre x86_64 debug=n Not tainted ]----
(XEN) CPU: 1
(XEN) RIP: 0060:[<000000000000002a>]
(XEN) RFLAGS: 0000000000023202 CONTEXT: hvm guest
(XEN) rax: 0000000000000007 rbx: 0000000000001490 rcx:

0000000000000000

Quoted 1 line

(XEN) rdx: 0000000000001da8 rsi: 0000000000000000 rdi:

0000000000000000

Quoted 1 line

(XEN) rbp: 0000000000008ebf rsp: 0000000000000080 r8:

0000000000000000

Quoted 1 line

(XEN) r9: 0000000000000000 r10: 0000000000000000 r11:

0000000000000000

Quoted 1 line

(XEN) r12: 0000000000000000 r13: 0000000000000000 r14:

0000000000000000

Quoted 1 line

(XEN) r15: 0000000000000000 cr0: 0000000080000019 cr4:

0000000000000000

Quoted 4 lines

(XEN) cr3: 0000000001443000 cr2: 0000000000000000
(XEN) ds: 0068 es: 0068 fs: 0068 gs: 0068 ss: 0070 cs: 0060

Could it be, that the real mode emulation code has a bug? What does this

error means?

Quoted 4 lines

Tom

2009/4/22 Keir Fraser <[email protected]<mailto:

[email protected]>>

Quoted 1 line

On 22/04/2009 12:18, "Tom Rotenberg" <[email protected]<mailto:

Quoted 4 lines · [email protected]>> wrote:
Quoted 4 lines

Keir,

I have applied your patch, and it seemed to work. However, the domain

still

Quoted 3 lines
Quoted 1 line

crashes, and now it looks like it's because of the 'LTR' instruction.

Try the attached patch. It replaces the one I sent last time, and

emulates

Quoted 4 lines

both LLDT and LTR.

-- Keir

Content-Description: ATT00001.txt

Quoted 4 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

Quoted 5 lines

--
Tim Deegan <[email protected]>
Principal Software Engineer, Citrix Systems (R&D) Ltd. [Company #02300071, SL9 0DZ, UK.]

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#9 lore raw
Quoted 4 lines · Tom Rotenberg

so what does it mean? could it be that we have a bug in the real mode emulation, which causes the segment state to be invalid (maybe it's because of a bug in the patch that Keir made for me, which emulated the LLDT, and the LTR instructions)?

It means probably that Xen doesn't support the guest using virtual 8086 mode. Adding support probably wouldn't be too hard, by treating virtual 8086 mode as a special case of real mode, but I don't have time to look at it right now.

Tim.

Quoted 112 lines

Keir suggested to trace back where the problem (segment state) occured, and from there to try and find the bug which caused it. Do u have any better suggestion for solving this?

Tom

2009/4/22 Tim Deegan <[email protected]<mailto:[email protected]>>

Quoted 4 lines · Tom Rotenberg

Keir,

I have tried your latest patch, and it looks like now it passes the emulation problem. However, now the domain crashes with the following error:

Quoted 11 lines

(XEN) HVM1: Booting from 0000:7c00
(XEN) Failed vm entry (exit reason 0x80000021) caused by invalid guest state (0). (XEN) ************* VMCS Area **************
(XEN) *** Guest State ***
(XEN) CR0: actual=0x0000000080010039, shadow=0x0000000080000019, gh_mask=ffffffffffffffff (XEN) CR4: actual=0x0000000000002060, shadow=0x0000000000000000, gh_mask=ffffffffffffffff (XEN) CR3: actual=0x000000000a213a20, target_count=0
(XEN) target0=0000000000000000, target1=0000000000000000
(XEN) target2=0000000000000000, target3=0000000000000000
(XEN) RSP = 0x0000000000000080 (0x0000000000000080) RIP = 0x000000000000002a (0x000000000000002a) (XEN) RFLAGS=0x0000000000023202 (0x0000000000023202) DR7 = 0x0000000000000400

Looks like we're trying to VMENTER in virtual 8086 mode but without tidying up the segment state. That could either be the guest entering virtual 8086 mode itself or Xen entering vitrual 8086 mode to emulate real mode, but Xen is always careful to make the segment state agree with Intel's rather strict requrements when it does that.

Tim.

Quoted 59 lines

(XEN) Sysenter RSP=0000000000000000 CS:RIP=0000:0000000000000000 (XEN) CS: sel=0x0060, attr=0x0c09b, limit=0xffffffff, base=0x0000000000200000 (XEN) DS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000 (XEN) SS: sel=0x0070, attr=0x0c093, limit=0xfc000fff, base=0x000000000020ba62 (XEN) ES: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000 (XEN) FS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000 (XEN) GS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) GDTR: limit=0x00001dd8, base=0x0000000000200000
(XEN) LDTR: sel=0x0000, attr=0x1c000, limit=0xffffffff, base=0x0000000000000000
(XEN) IDTR: limit=0x00000188, base=0x0000000000201df0
(XEN) TR: sel=0x0058, attr=0x0008b, limit=0x0000ffff, base=0x0000000000201ff2 (XEN) Guest PAT = 0x0000000000000000
(XEN) TSC Offset = ffffffe4920110b7
(XEN) DebugCtl=0000000000000000 DebugExceptions=0000000000000000 (XEN) Interruptibility=0001 ActivityState=0000
(XEN) *** Host State ***
(XEN) RSP = 0xffff83007e4f7fa0 RIP = 0xffff828c8019aa20
(XEN) CS=e008 DS=0000 ES=0000 FS=0000 GS=0000 SS=0000 TR=e040 (XEN) FSBase=0000000000000000 GSBase=0000000000000000 TRBase=ffff828c802a8b00 (XEN) GDTBase=ffff83007e9a3000 IDTBase=ffff83007e62e010
(XEN) CR0=0000000080050033 CR3=000000007cfdc000 CR4=00000000000026f0 (XEN) Sysenter RSP=ffff83007e4f7fd0 CS:RIP=e008:ffff828c801c7290 (XEN) Host PAT = 0x0000000000000000
(XEN) *** Control State ***
(XEN) PinBased=0000003f CPUBased=b6a1e7fe SecondaryExec=00000041 (XEN) EntryControls=000011ff ExitControls=0003efff
(XEN) ExceptionBitmap=00044080
(XEN) VMEntry: intr_info=80000b0b errcode=00001eac ilen=00000000 (XEN) VMExit: intr_info=00000000 errcode=00008000 ilen=00000000
(XEN) reason=80000021 qualification=00000000
(XEN) IDTVectoring: info=00000000 errcode=00000000
(XEN) TPR Threshold = 0x00
(XEN) EPT pointer = 0x0000000000000000
(XEN) Virtual processor ID = 0x0000
(XEN) **************************************
(XEN) domain_crash called from vmx.c:2218
(XEN) Domain 1 (vcpu#0) crashed on cpu#1:
(XEN) ----[ Xen-3.4.0-rc3-pre x86_64 debug=n Not tainted ]----
(XEN) CPU: 1
(XEN) RIP: 0060:[<000000000000002a>]
(XEN) RFLAGS: 0000000000023202 CONTEXT: hvm guest

(XEN) rax: 0000000000000007   rbx: 0000000000001490   rcx: 0000000000000000
(XEN) rdx: 0000000000001da8   rsi: 0000000000000000   rdi: 0000000000000000
(XEN) rbp: 0000000000008ebf   rsp: 0000000000000080   r8:  0000000000000000
(XEN) r9:  0000000000000000   r10: 0000000000000000   r11: 0000000000000000
(XEN) r12: 0000000000000000   r13: 0000000000000000   r14: 0000000000000000
(XEN) r15: 0000000000000000   cr0: 0000000080000019   cr4: 0000000000000000
(XEN) cr3: 0000000001443000   cr2: 0000000000000000

(XEN) ds: 0068 es: 0068 fs: 0068 gs: 0068 ss: 0070 cs: 0060

Could it be, that the real mode emulation code has a bug? What does this error means?

Tom

2009/4/22 Keir Fraser <[email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>>>

Quoted 2 lines · On 22/04/2009 12:18, "Tom Rotenberg" <[email protected]<mailto:tom.rotenb…

Keir,

Quoted 8 lines
Quoted 2 lines

I have applied your patch, and it seemed to work. However, the domain still crashes, and now it looks like it's because of the 'LTR' instruction.

Try the attached patch. It replaces the one I sent last time, and emulates both LLDT and LTR.

-- Keir

Content-Description: ATT00001.txt

Quoted 4 lines

_______________________________________________
Xen-devel mailing list [email protected]<mailto:[email protected]>
http://lists.xensource.com/xen-devel

--
Tim Deegan <[email protected]<mailto:[email protected]>> Principal Software Engineer, Citrix Systems (R&D) Ltd. [Company #02300071, SL9 0DZ, UK.]

Signature · 3 lines
Tim Deegan <[email protected]>
Principal Software Engineer, Citrix Systems (R&D) Ltd.
[Company #02300071, SL9 0DZ, UK.]
#10 lore raw
In reply to Tom Rotenberg

It could be an issue with the vm86 acceleration, possibly. I'm pretty sure the guest would have to IRET from protected mode to enter vm86 mode itself, and we don't emulate that. Tim: what would we need to do to disable the vm86 acceleration for testing purposes? You suggested not setting VM86_TSS param from hvmloader, but I couldn't convince myself what effect that would actually have as the logic in Xen is non-trivial.

-- Keir

Quoted 141 lines · Tom Rotenberg

Tim,

so what does it mean? could it be that we have a bug in the real mode emulation, which causes the segment state to be invalid (maybe it's because of a bug in the patch that Keir made for me, which emulated the LLDT, and the LTR instructions)?

Keir suggested to trace back where the problem (segment state) occured, and from there to try and find the bug which caused it. Do u have any better suggestion for solving this?

Tom

2009/4/22 Tim Deegan <[email protected]>

Quoted 126 lines
Quoted 6 lines · Tom Rotenberg

Keir,

I have tried your latest patch, and it looks like now it passes the emulation problem. However,  now the domain crashes with the following error:

Quoted 16 lines

(XEN) HVM1: Booting from 0000:7c00
(XEN) Failed vm entry (exit reason 0x80000021) caused by invalid guest state (0).
(XEN) ************* VMCS Area **************
(XEN) *** Guest State ***
(XEN) CR0: actual=0x0000000080010039, shadow=0x0000000080000019, gh_mask=ffffffffffffffff
(XEN) CR4: actual=0x0000000000002060, shadow=0x0000000000000000, gh_mask=ffffffffffffffff
(XEN) CR3: actual=0x000000000a213a20, target_count=0
(XEN)      target0=0000000000000000, target1=0000000000000000 (XEN)      target2=0000000000000000, target3=0000000000000000 (XEN) RSP = 0x0000000000000080 (0x0000000000000080)  RIP = 0x000000000000002a (0x000000000000002a)
(XEN) RFLAGS=0x0000000000023202 (0x0000000000023202)  DR7 = 0x0000000000000400

Looks like we're trying to VMENTER in virtual 8086 mode but without tidying up the segment state.  That could either be the guest entering virtual 8086 mode itself or Xen entering vitrual 8086 mode to emulate real mode, but Xen is always careful to make the segment state agree with Intel's rather strict requrements when it does that.

Tim.

Quoted 73 lines

(XEN) Sysenter RSP=0000000000000000 CS:RIP=0000:0000000000000000 (XEN) CS: sel=0x0060, attr=0x0c09b, limit=0xffffffff, base=0x0000000000200000
(XEN) DS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) SS: sel=0x0070, attr=0x0c093, limit=0xfc000fff, base=0x000000000020ba62
(XEN) ES: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) FS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) GS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) GDTR:                           limit=0x00001dd8, base=0x0000000000200000
(XEN) LDTR: sel=0x0000, attr=0x1c000, limit=0xffffffff, base=0x0000000000000000
(XEN) IDTR:                           limit=0x00000188, base=0x0000000000201df0
(XEN) TR: sel=0x0058, attr=0x0008b, limit=0x0000ffff, base=0x0000000000201ff2
(XEN) Guest PAT = 0x0000000000000000
(XEN) TSC Offset = ffffffe4920110b7
(XEN) DebugCtl=0000000000000000 DebugExceptions=0000000000000000 (XEN) Interruptibility=0001 ActivityState=0000
(XEN) *** Host State ***
(XEN) RSP = 0xffff83007e4f7fa0  RIP = 0xffff828c8019aa20
(XEN) CS=e008 DS=0000 ES=0000 FS=0000 GS=0000 SS=0000 TR=e040 (XEN) FSBase=0000000000000000 GSBase=0000000000000000 TRBase=ffff828c802a8b00
(XEN) GDTBase=ffff83007e9a3000 IDTBase=ffff83007e62e010
(XEN) CR0=0000000080050033 CR3=000000007cfdc000 CR4=00000000000026f0 (XEN) Sysenter RSP=ffff83007e4f7fd0 CS:RIP=e008:ffff828c801c7290 (XEN) Host PAT = 0x0000000000000000
(XEN) *** Control State ***
(XEN) PinBased=0000003f CPUBased=b6a1e7fe SecondaryExec=00000041 (XEN) EntryControls=000011ff ExitControls=0003efff
(XEN) ExceptionBitmap=00044080
(XEN) VMEntry: intr_info=80000b0b errcode=00001eac ilen=00000000 (XEN) VMExit: intr_info=00000000 errcode=00008000 ilen=00000000 (XEN)         reason=80000021 qualification=00000000
(XEN) IDTVectoring: info=00000000 errcode=00000000
(XEN) TPR Threshold = 0x00
(XEN) EPT pointer = 0x0000000000000000
(XEN) Virtual processor ID = 0x0000
(XEN) **************************************
(XEN) domain_crash called from vmx.c:2218
(XEN) Domain 1 (vcpu#0) crashed on cpu#1:
(XEN) ----[ Xen-3.4.0-rc3-pre  x86_64  debug=n  Not tainted ]---- (XEN) CPU:    1
(XEN) RIP:    0060:[<000000000000002a>]
(XEN) RFLAGS: 0000000000023202   CONTEXT: hvm guest
(XEN) rax: 0000000000000007   rbx: 0000000000001490   rcx: 0000000000000000 (XEN) rdx: 0000000000001da8   rsi: 0000000000000000   rdi: 0000000000000000 (XEN) rbp: 0000000000008ebf   rsp: 0000000000000080   r8:  0000000000000000 (XEN) r9:  0000000000000000   r10: 0000000000000000   r11: 0000000000000000 (XEN) r12: 0000000000000000   r13: 0000000000000000   r14: 0000000000000000 (XEN) r15: 0000000000000000   cr0: 0000000080000019   cr4: 0000000000000000 (XEN) cr3: 0000000001443000   cr2: 0000000000000000
(XEN) ds: 0068   es: 0068   fs: 0068   gs: 0068   ss: 0070   cs: 0060

Could it be, that the real mode emulation code has a bug? What does this error means?

Tom

2009/4/22 Keir Fraser <[email protected]<mailto:[email protected]>>

Quoted 2 lines · On 22/04/2009 12:18, "Tom Rotenberg" <[email protected]<mailto:tom.rotenb…

Keir,

Quoted 8 lines
Quoted 2 lines

I have applied your patch, and it seemed to work. However, the domain still crashes, and now it looks like it's because of the 'LTR' instruction.

Try the attached patch. It replaces the one I sent last time, and emulates both LLDT and LTR.

 -- Keir

Content-Description: ATT00001.txt

Quoted 4 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

--
Tim Deegan <[email protected]>
Principal Software Engineer, Citrix Systems (R&D) Ltd. [Company #02300071, SL9 0DZ, UK.]

#11 lore raw
Quoted 6 lines · Keir Fraser

It could be an issue with the vm86 acceleration, possibly. I'm pretty sure the guest would have to IRET from protected mode to enter vm86 mode itself, and we don't emulate that. Tim: what would we need to do to disable the vm86 acceleration for testing purposes? You suggested not setting VM86_TSS param from hvmloader, but I couldn't convince myself what effect that would actually have as the logic in Xen is non-trivial.

Yes; if HVM_PARAM_VM86_TSS is zero, vmx_set_segment_register() will always set the tss bit in the bitmap of segments that aren't safe to enter VM86 with.

Tim.

Quoted 148 lines

-- Keir

Quoted 141 lines · Tom Rotenberg

Tim,

so what does it mean? could it be that we have a bug in the real mode emulation, which causes the segment state to be invalid (maybe it's because of a bug in the patch that Keir made for me, which emulated the LLDT, and the LTR instructions)?

Keir suggested to trace back where the problem (segment state) occured, and from there to try and find the bug which caused it. Do u have any better suggestion for solving this?

Tom

2009/4/22 Tim Deegan <[email protected]>

Quoted 126 lines
Quoted 6 lines · Tom Rotenberg

Keir,

I have tried your latest patch, and it looks like now it passes the emulation problem. However,  now the domain crashes with the following error:

Quoted 16 lines

(XEN) HVM1: Booting from 0000:7c00
(XEN) Failed vm entry (exit reason 0x80000021) caused by invalid guest state (0).
(XEN) ************* VMCS Area **************
(XEN) *** Guest State ***
(XEN) CR0: actual=0x0000000080010039, shadow=0x0000000080000019, gh_mask=ffffffffffffffff
(XEN) CR4: actual=0x0000000000002060, shadow=0x0000000000000000, gh_mask=ffffffffffffffff
(XEN) CR3: actual=0x000000000a213a20, target_count=0
(XEN)      target0=0000000000000000, target1=0000000000000000 (XEN)      target2=0000000000000000, target3=0000000000000000 (XEN) RSP = 0x0000000000000080 (0x0000000000000080)  RIP = 0x000000000000002a (0x000000000000002a)
(XEN) RFLAGS=0x0000000000023202 (0x0000000000023202)  DR7 = 0x0000000000000400

Looks like we're trying to VMENTER in virtual 8086 mode but without tidying up the segment state.  That could either be the guest entering virtual 8086 mode itself or Xen entering vitrual 8086 mode to emulate real mode, but Xen is always careful to make the segment state agree with Intel's rather strict requrements when it does that.

Tim.

Quoted 73 lines

(XEN) Sysenter RSP=0000000000000000 CS:RIP=0000:0000000000000000 (XEN) CS: sel=0x0060, attr=0x0c09b, limit=0xffffffff, base=0x0000000000200000
(XEN) DS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) SS: sel=0x0070, attr=0x0c093, limit=0xfc000fff, base=0x000000000020ba62
(XEN) ES: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) FS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) GS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) GDTR:                           limit=0x00001dd8, base=0x0000000000200000
(XEN) LDTR: sel=0x0000, attr=0x1c000, limit=0xffffffff, base=0x0000000000000000
(XEN) IDTR:                           limit=0x00000188, base=0x0000000000201df0
(XEN) TR: sel=0x0058, attr=0x0008b, limit=0x0000ffff, base=0x0000000000201ff2
(XEN) Guest PAT = 0x0000000000000000
(XEN) TSC Offset = ffffffe4920110b7
(XEN) DebugCtl=0000000000000000 DebugExceptions=0000000000000000 (XEN) Interruptibility=0001 ActivityState=0000
(XEN) *** Host State ***
(XEN) RSP = 0xffff83007e4f7fa0  RIP = 0xffff828c8019aa20
(XEN) CS=e008 DS=0000 ES=0000 FS=0000 GS=0000 SS=0000 TR=e040 (XEN) FSBase=0000000000000000 GSBase=0000000000000000 TRBase=ffff828c802a8b00
(XEN) GDTBase=ffff83007e9a3000 IDTBase=ffff83007e62e010
(XEN) CR0=0000000080050033 CR3=000000007cfdc000 CR4=00000000000026f0 (XEN) Sysenter RSP=ffff83007e4f7fd0 CS:RIP=e008:ffff828c801c7290 (XEN) Host PAT = 0x0000000000000000
(XEN) *** Control State ***
(XEN) PinBased=0000003f CPUBased=b6a1e7fe SecondaryExec=00000041 (XEN) EntryControls=000011ff ExitControls=0003efff
(XEN) ExceptionBitmap=00044080
(XEN) VMEntry: intr_info=80000b0b errcode=00001eac ilen=00000000 (XEN) VMExit: intr_info=00000000 errcode=00008000 ilen=00000000 (XEN)         reason=80000021 qualification=00000000
(XEN) IDTVectoring: info=00000000 errcode=00000000
(XEN) TPR Threshold = 0x00
(XEN) EPT pointer = 0x0000000000000000
(XEN) Virtual processor ID = 0x0000
(XEN) **************************************
(XEN) domain_crash called from vmx.c:2218
(XEN) Domain 1 (vcpu#0) crashed on cpu#1:
(XEN) ----[ Xen-3.4.0-rc3-pre  x86_64  debug=n  Not tainted ]---- (XEN) CPU:    1
(XEN) RIP:    0060:[<000000000000002a>]
(XEN) RFLAGS: 0000000000023202   CONTEXT: hvm guest
(XEN) rax: 0000000000000007   rbx: 0000000000001490   rcx: 0000000000000000 (XEN) rdx: 0000000000001da8   rsi: 0000000000000000   rdi: 0000000000000000 (XEN) rbp: 0000000000008ebf   rsp: 0000000000000080   r8:  0000000000000000 (XEN) r9:  0000000000000000   r10: 0000000000000000   r11: 0000000000000000 (XEN) r12: 0000000000000000   r13: 0000000000000000   r14: 0000000000000000 (XEN) r15: 0000000000000000   cr0: 0000000080000019   cr4: 0000000000000000 (XEN) cr3: 0000000001443000   cr2: 0000000000000000
(XEN) ds: 0068   es: 0068   fs: 0068   gs: 0068   ss: 0070   cs: 0060

Could it be, that the real mode emulation code has a bug? What does this error means?

Tom

2009/4/22 Keir Fraser <[email protected]<mailto:[email protected]>>

Quoted 2 lines · On 22/04/2009 12:18, "Tom Rotenberg" <[email protected]<mailto:tom.rotenb…

Keir,

Quoted 8 lines
Quoted 2 lines

I have applied your patch, and it seemed to work. However, the domain still crashes, and now it looks like it's because of the 'LTR' instruction.

Try the attached patch. It replaces the one I sent last time, and emulates both LLDT and LTR.

 -- Keir

Content-Description: ATT00001.txt

Quoted 4 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

--
Tim Deegan <[email protected]>
Principal Software Engineer, Citrix Systems (R&D) Ltd. [Company #02300071, SL9 0DZ, UK.]

Signature · 3 lines
Tim Deegan <[email protected]>
Principal Software Engineer, Citrix Systems (R&D) Ltd.
[Company #02300071, SL9 0DZ, UK.]
#12 lore raw

So, do u suggest, that i will set HVM_PARAM_VM86_TSS to 0, and re-check it?

2009/4/22 Tim Deegan <[email protected]>

Quoted 183 lines
Quoted 1 line · Keir Fraser

It could be an issue with the vm86 acceleration, possibly. I'm pretty

sure

Quoted 1 line

the guest would have to IRET from protected mode to enter vm86 mode

itself,

Quoted 1 line

and we don't emulate that. Tim: what would we need to do to disable the

vm86

Quoted 1 line

acceleration for testing purposes? You suggested not setting VM86_TSS

param

Quoted 2 lines

from hvmloader, but I couldn't convince myself what effect that would actually have as the logic in Xen is non-trivial.

Yes; if HVM_PARAM_VM86_TSS is zero, vmx_set_segment_register() will always set the tss bit in the bitmap of segments that aren't safe to enter VM86 with.

Tim.

Quoted 9 lines

-- Keir

Quoted 4 lines · Tom Rotenberg

Tim,

so what does it mean? could it be that we have a bug in the real mode emulation, which causes the segment state to be invalid (maybe it's

because of

Quoted 1 line
Quoted 1 line

a bug in the patch that Keir made for me, which emulated the LLDT, and

the LTR

Quoted 3 lines
Quoted 3 lines

instructions)?

Keir suggested to trace back where the problem (segment state) occured,

and

Quoted 1 line
Quoted 1 line

from there to try and find the bug which caused it. Do u have any

better

Quoted 10 lines
Quoted 10 lines

suggestion for solving this?

Tom

2009/4/22 Tim Deegan <[email protected]>

Quoted 5 lines
Quoted 4 lines · Tom Rotenberg

Keir,

I have tried your latest patch, and it looks like now it passes the emulation problem. However, now the domain crashes with the

following

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

error:

(XEN) HVM1: Booting from 0000:7c00
(XEN) Failed vm entry (exit reason 0x80000021) caused by invalid

guest state

Quoted 69 lines
Quoted 69 lines
Quoted 69 lines
Quoted 6 lines

(0).
(XEN) ************* VMCS Area **************
(XEN) *** Guest State ***
(XEN) CR0: actual=0x0000000080010039, shadow=0x0000000080000019, gh_mask=ffffffffffffffff
(XEN) CR4: actual=0x0000000000002060, shadow=0x0000000000000000,

Quoted 8 lines

gh_mask=ffffffffffffffff
(XEN) CR3: actual=0x000000000a213a20, target_count=0
(XEN) target0=0000000000000000, target1=0000000000000000
(XEN) target2=0000000000000000, target3=0000000000000000
(XEN) RSP = 0x0000000000000080 (0x0000000000000080) RIP = 0x000000000000002a (0x000000000000002a)
(XEN) RFLAGS=0x0000000000023202 (0x0000000000023202) DR7 = 0x0000000000000400

Looks like we're trying to VMENTER in virtual 8086 mode but without tidying up the segment state. That could either be the guest entering virtual 8086 mode itself or Xen entering vitrual 8086 mode to emulate real mode, but Xen is always careful to make the segment state agree with Intel's rather strict requrements when it does that.

Tim.

Quoted 45 lines

(XEN) Sysenter RSP=0000000000000000 CS:RIP=0000:0000000000000000 (XEN) CS: sel=0x0060, attr=0x0c09b, limit=0xffffffff, base=0x0000000000200000
(XEN) DS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) SS: sel=0x0070, attr=0x0c093, limit=0xfc000fff, base=0x000000000020ba62
(XEN) ES: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) FS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) GS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) GDTR: limit=0x00001dd8,
base=0x0000000000200000
(XEN) LDTR: sel=0x0000, attr=0x1c000, limit=0xffffffff, base=0x0000000000000000
(XEN) IDTR: limit=0x00000188,
base=0x0000000000201df0
(XEN) TR: sel=0x0058, attr=0x0008b, limit=0x0000ffff, base=0x0000000000201ff2
(XEN) Guest PAT = 0x0000000000000000
(XEN) TSC Offset = ffffffe4920110b7
(XEN) DebugCtl=0000000000000000 DebugExceptions=0000000000000000 (XEN) Interruptibility=0001 ActivityState=0000
(XEN) *** Host State ***
(XEN) RSP = 0xffff83007e4f7fa0 RIP = 0xffff828c8019aa20 (XEN) CS=e008 DS=0000 ES=0000 FS=0000 GS=0000 SS=0000 TR=e040 (XEN) FSBase=0000000000000000 GSBase=0000000000000000 TRBase=ffff828c802a8b00
(XEN) GDTBase=ffff83007e9a3000 IDTBase=ffff83007e62e010 (XEN) CR0=0000000080050033 CR3=000000007cfdc000 CR4=00000000000026f0 (XEN) Sysenter RSP=ffff83007e4f7fd0 CS:RIP=e008:ffff828c801c7290 (XEN) Host PAT = 0x0000000000000000
(XEN) *** Control State ***
(XEN) PinBased=0000003f CPUBased=b6a1e7fe SecondaryExec=00000041 (XEN) EntryControls=000011ff ExitControls=0003efff
(XEN) ExceptionBitmap=00044080
(XEN) VMEntry: intr_info=80000b0b errcode=00001eac ilen=00000000 (XEN) VMExit: intr_info=00000000 errcode=00008000 ilen=00000000
(XEN) reason=80000021 qualification=00000000
(XEN) IDTVectoring: info=00000000 errcode=00000000
(XEN) TPR Threshold = 0x00
(XEN) EPT pointer = 0x0000000000000000
(XEN) Virtual processor ID = 0x0000

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

(XEN) **************************************
(XEN) domain_crash called from vmx.c:2218
(XEN) Domain 1 (vcpu#0) crashed on cpu#1:
(XEN) ----[ Xen-3.4.0-rc3-pre x86_64 debug=n Not tainted ]----
(XEN) CPU: 1
(XEN) RIP: 0060:[<000000000000002a>]
(XEN) RFLAGS: 0000000000023202 CONTEXT: hvm guest
(XEN) rax: 0000000000000007 rbx: 0000000000001490 rcx:

0000000000000000

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

(XEN) rdx: 0000000000001da8 rsi: 0000000000000000 rdi:

0000000000000000

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

(XEN) rbp: 0000000000008ebf rsp: 0000000000000080 r8:

0000000000000000

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

(XEN) r9: 0000000000000000 r10: 0000000000000000 r11:

0000000000000000

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

(XEN) r12: 0000000000000000 r13: 0000000000000000 r14:

0000000000000000

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

(XEN) r15: 0000000000000000 cr0: 0000000080000019 cr4:

0000000000000000

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

(XEN) cr3: 0000000001443000 cr2: 0000000000000000
(XEN) ds: 0068 es: 0068 fs: 0068 gs: 0068 ss: 0070 cs: 0060

Could it be, that the real mode emulation code has a bug? What does

this

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

error means?

Tom

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

2009/4/22 Keir Fraser <[email protected]<mailto:[email protected]>>

Quoted 3 lines · On 22/04/2009 12:18, "Tom Rotenberg" <[email protected]<mailto:tom.rotenb…

Keir,

I have applied your patch, and it seemed to work. However, the

domain still

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

crashes, and now it looks like it's because of the 'LTR'

instruction.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Try the attached patch. It replaces the one I sent last time, and

emulates

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 4 lines

both LLDT and LTR.

-- Keir

Content-Description: ATT00001.txt

Quoted 4 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

Quoted 7 lines
Quoted 5 lines
Quoted 4 lines

--
Tim Deegan <[email protected]>
Principal Software Engineer, Citrix Systems (R&D) Ltd. [Company #02300071, SL9 0DZ, UK.]

Quoted 5 lines

--
Tim Deegan <[email protected]>
Principal Software Engineer, Citrix Systems (R&D) Ltd. [Company #02300071, SL9 0DZ, UK.]

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#13 lore raw

Yes, the safest way to be sure is probably to replace the if() statement in vmx_set_segment_register() that tests HVM_PARAM_VM86_TSS with if(0). That is the only place in Xen that checks HVM_PARAM_VM86_TSS. Then you can re-build/install Xen and be sure that vm86 accel must be disabled.

-- Keir

Quoted 182 lines · Tom Rotenberg

So, do u suggest, that i will set HVM_PARAM_VM86_TSS to 0, and re-check it?

2009/4/22 Tim Deegan <[email protected]>

Quoted 178 lines
Quoted 6 lines · Keir Fraser

It could be an issue with the vm86 acceleration, possibly. I'm pretty sure the guest would have to IRET from protected mode to enter vm86 mode itself, and we don't emulate that. Tim: what would we need to do to disable the vm86 acceleration for testing purposes? You suggested not setting VM86_TSS param from hvmloader, but I couldn't convince myself what effect that would actually have as the logic in Xen is non-trivial.

Yes; if HVM_PARAM_VM86_TSS is zero, vmx_set_segment_register() will always set the tss bit in the bitmap of segments that aren't safe to enter VM86 with.

Tim.

Quoted 159 lines

 -- Keir

Quoted 152 lines · Tom Rotenberg

Tim,

so what does it mean? could it be that we have a bug in the real mode emulation, which causes the segment state to be invalid (maybe it's because of
a bug in the patch that Keir made for me, which emulated the LLDT, and the LTR
instructions)?

Keir suggested to trace back where the problem (segment state) occured, and from there to try and find the bug which caused it. Do u have any better suggestion for solving this?

Tom

2009/4/22 Tim Deegan <[email protected]>

Quoted 135 lines
Quoted 15 lines · Tom Rotenberg

Keir,

I have tried your latest patch, and it looks like now it passes the emulation problem. However,  now the domain crashes with the following error:

(XEN) HVM1: Booting from 0000:7c00
(XEN) Failed vm entry (exit reason 0x80000021) caused by invalid guest state
(0).
(XEN) ************* VMCS Area **************
(XEN) *** Guest State ***
(XEN) CR0: actual=0x0000000080010039, shadow=0x0000000080000019, gh_mask=ffffffffffffffff
(XEN) CR4: actual=0x0000000000002060, shadow=0x0000000000000000,

Quoted 8 lines

gh_mask=ffffffffffffffff
(XEN) CR3: actual=0x000000000a213a20, target_count=0 (XEN)      target0=0000000000000000, target1=0000000000000000 (XEN)      target2=0000000000000000, target3=0000000000000000 (XEN) RSP = 0x0000000000000080 (0x0000000000000080)  RIP = 0x000000000000002a (0x000000000000002a)
(XEN) RFLAGS=0x0000000000023202 (0x0000000000023202)  DR7 = 0x0000000000000400

Looks like we're trying to VMENTER in virtual 8086 mode but without tidying up the segment state.  That could either be the guest entering virtual 8086 mode itself or Xen entering vitrual 8086 mode to emulate real mode, but Xen is always careful to make the segment state agree with Intel's rather strict requrements when it does that.

Tim.

Quoted 83 lines

(XEN) Sysenter RSP=0000000000000000 CS:RIP=0000:0000000000000000 (XEN) CS: sel=0x0060, attr=0x0c09b, limit=0xffffffff, base=0x0000000000200000
(XEN) DS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) SS: sel=0x0070, attr=0x0c093, limit=0xfc000fff, base=0x000000000020ba62
(XEN) ES: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) FS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) GS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) GDTR:                           limit=0x00001dd8, base=0x0000000000200000
(XEN) LDTR: sel=0x0000, attr=0x1c000, limit=0xffffffff, base=0x0000000000000000
(XEN) IDTR:                           limit=0x00000188, base=0x0000000000201df0
(XEN) TR: sel=0x0058, attr=0x0008b, limit=0x0000ffff, base=0x0000000000201ff2
(XEN) Guest PAT = 0x0000000000000000
(XEN) TSC Offset = ffffffe4920110b7
(XEN) DebugCtl=0000000000000000 DebugExceptions=0000000000000000 (XEN) Interruptibility=0001 ActivityState=0000
(XEN) *** Host State ***
(XEN) RSP = 0xffff83007e4f7fa0  RIP = 0xffff828c8019aa20 (XEN) CS=e008 DS=0000 ES=0000 FS=0000 GS=0000 SS=0000 TR=e040 (XEN) FSBase=0000000000000000 GSBase=0000000000000000 TRBase=ffff828c802a8b00
(XEN) GDTBase=ffff83007e9a3000 IDTBase=ffff83007e62e010 (XEN) CR0=0000000080050033 CR3=000000007cfdc000 CR4=00000000000026f0 (XEN) Sysenter RSP=ffff83007e4f7fd0 CS:RIP=e008:ffff828c801c7290 (XEN) Host PAT = 0x0000000000000000
(XEN) *** Control State ***
(XEN) PinBased=0000003f CPUBased=b6a1e7fe SecondaryExec=00000041 (XEN) EntryControls=000011ff ExitControls=0003efff
(XEN) ExceptionBitmap=00044080
(XEN) VMEntry: intr_info=80000b0b errcode=00001eac ilen=00000000 (XEN) VMExit: intr_info=00000000 errcode=00008000 ilen=00000000 (XEN)         reason=80000021 qualification=00000000
(XEN) IDTVectoring: info=00000000 errcode=00000000
(XEN) TPR Threshold = 0x00
(XEN) EPT pointer = 0x0000000000000000
(XEN) Virtual processor ID = 0x0000
(XEN) **************************************
(XEN) domain_crash called from vmx.c:2218
(XEN) Domain 1 (vcpu#0) crashed on cpu#1:
(XEN) ----[ Xen-3.4.0-rc3-pre  x86_64  debug=n  Not tainted ]---- (XEN) CPU:    1
(XEN) RIP:    0060:[<000000000000002a>]
(XEN) RFLAGS: 0000000000023202   CONTEXT: hvm guest
(XEN) rax: 0000000000000007   rbx: 0000000000001490   rcx:
0000000000000000
(XEN) rdx: 0000000000001da8   rsi: 0000000000000000   rdi:
0000000000000000
(XEN) rbp: 0000000000008ebf   rsp: 0000000000000080   r8:
 0000000000000000
(XEN) r9:  0000000000000000   r10: 0000000000000000   r11:
0000000000000000
(XEN) r12: 0000000000000000   r13: 0000000000000000   r14:
0000000000000000
(XEN) r15: 0000000000000000   cr0: 0000000080000019   cr4:
0000000000000000
(XEN) cr3: 0000000001443000   cr2: 0000000000000000
(XEN) ds: 0068   es: 0068   fs: 0068   gs: 0068   ss: 0070   cs: 0060

Could it be, that the real mode emulation code has a bug? What does this error means?

Tom

2009/4/22 Keir Fraser <[email protected]<mailto:[email protected]>>

Quoted 5 lines · On 22/04/2009 12:18, "Tom Rotenberg" <[email protected]<mailto:tom.rotenb…

Keir,

I have applied your patch, and it seemed to work. However, the domain still
crashes, and now it looks like it's because of the 'LTR' instruction.

Quoted 6 lines

Try the attached patch. It replaces the one I sent last time, and emulates
both LLDT and LTR.

 -- Keir

Content-Description: ATT00001.txt

Quoted 4 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

--
Tim Deegan <[email protected]>
Principal Software Engineer, Citrix Systems (R&D) Ltd. [Company #02300071, SL9 0DZ, UK.]

--
Tim Deegan <[email protected]>
Principal Software Engineer, Citrix Systems (R&D) Ltd. [Company #02300071, SL9 0DZ, UK.]

#14 lore raw

Keir,
Just to make sure, i am using the following patch, in order to disable the vm86 acceleration:

xen/arch/x86/hvm/vmx/vmx.c Wed Apr 22 17:03:20 2009 +0300 renamed from xen/arch/x86/hvm/vmx/vmx.c Wed Apr 22 11:26:37 2009 +0100 +1 -1
diff -r cdc044f665dc xen/arch/x86/hvm/vmx/vmx.c
@@ -829,7 +829,7 @@
 
         if ( seg == x86_seg_tr )
         {
-            if ( v->domain->arch.hvm_domain.params[HVM_PARAM_VM86_TSS] )
+            if (0)
             {
                 sel = 0;
                 attr = vm86_tr_attr;

Is this OK?

Tom

2009/4/22 Keir Fraser <[email protected]>

Quoted 173 lines

Yes, the safest way to be sure is probably to replace the if() statement in vmx_set_segment_register() that tests HVM_PARAM_VM86_TSS with if(0). That is
the only place in Xen that checks HVM_PARAM_VM86_TSS. Then you can re-build/install Xen and be sure that vm86 accel must be disabled.

-- Keir

Quoted 1 line · Tom Rotenberg

So, do u suggest, that i will set HVM_PARAM_VM86_TSS to 0, and re-check

it?

Quoted 4 lines

2009/4/22 Tim Deegan <[email protected]>

Quoted 2 lines
Quoted 1 line · Keir Fraser

It could be an issue with the vm86 acceleration, possibly. I'm pretty

sure

Quoted 1 line
Quoted 1 line
Quoted 1 line

the guest would have to IRET from protected mode to enter vm86 mode

itself,

Quoted 1 line
Quoted 1 line
Quoted 1 line

and we don't emulate that. Tim: what would we need to do to disable the

vm86

Quoted 1 line
Quoted 1 line
Quoted 1 line

acceleration for testing purposes? You suggested not setting VM86_TSS

param

Quoted 10 lines
Quoted 10 lines
Quoted 2 lines

from hvmloader, but I couldn't convince myself what effect that would actually have as the logic in Xen is non-trivial.

Yes; if HVM_PARAM_VM86_TSS is zero, vmx_set_segment_register() will always set the tss bit in the bitmap of segments that aren't safe to enter VM86 with.

Tim.

Quoted 1 line
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

-- Keir

Quoted 4 lines · Tom Rotenberg

Tim,

so what does it mean? could it be that we have a bug in the real mode emulation, which causes the segment state to be invalid (maybe it's

because

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

of
a bug in the patch that Keir made for me, which emulated the LLDT, and

the

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

LTR
instructions)?

Keir suggested to trace back where the problem (segment state)

occured, and

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

from there to try and find the bug which caused it. Do u have any

better

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

suggestion for solving this?

Tom

2009/4/22 Tim Deegan <[email protected]>

Quoted 5 lines
Quoted 4 lines · Tom Rotenberg

Keir,

I have tried your latest patch, and it looks like now it passes the emulation problem. However, now the domain crashes with the

following

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

error:

(XEN) HVM1: Booting from 0000:7c00
(XEN) Failed vm entry (exit reason 0x80000021) caused by invalid

guest

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 15 lines

state
(0).
(XEN) ************* VMCS Area **************
(XEN) *** Guest State ***
(XEN) CR0: actual=0x0000000080010039, shadow=0x0000000080000019, gh_mask=ffffffffffffffff
(XEN) CR4: actual=0x0000000000002060, shadow=0x0000000000000000, gh_mask=ffffffffffffffff
(XEN) CR3: actual=0x000000000a213a20, target_count=0
(XEN) target0=0000000000000000, target1=0000000000000000
(XEN) target2=0000000000000000, target3=0000000000000000
(XEN) RSP = 0x0000000000000080 (0x0000000000000080) RIP = 0x000000000000002a (0x000000000000002a)
(XEN) RFLAGS=0x0000000000023202 (0x0000000000023202) DR7 = 0x0000000000000400

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Looks like we're trying to VMENTER in virtual 8086 mode but without tidying up the segment state. That could either be the guest

entering

Quoted 65 lines
Quoted 65 lines
Quoted 65 lines
Quoted 65 lines
Quoted 65 lines

virtual 8086 mode itself or Xen entering vitrual 8086 mode to emulate real mode, but Xen is always careful to make the segment state agree with Intel's rather strict requrements when it does that.

Tim.

Quoted 58 lines

(XEN) Sysenter RSP=0000000000000000 CS:RIP=0000:0000000000000000 (XEN) CS: sel=0x0060, attr=0x0c09b, limit=0xffffffff, base=0x0000000000200000
(XEN) DS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) SS: sel=0x0070, attr=0x0c093, limit=0xfc000fff, base=0x000000000020ba62
(XEN) ES: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) FS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) GS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) GDTR: limit=0x00001dd8,
base=0x0000000000200000
(XEN) LDTR: sel=0x0000, attr=0x1c000, limit=0xffffffff, base=0x0000000000000000
(XEN) IDTR: limit=0x00000188,
base=0x0000000000201df0
(XEN) TR: sel=0x0058, attr=0x0008b, limit=0x0000ffff, base=0x0000000000201ff2
(XEN) Guest PAT = 0x0000000000000000
(XEN) TSC Offset = ffffffe4920110b7
(XEN) DebugCtl=0000000000000000 DebugExceptions=0000000000000000 (XEN) Interruptibility=0001 ActivityState=0000
(XEN) *** Host State ***
(XEN) RSP = 0xffff83007e4f7fa0 RIP = 0xffff828c8019aa20 (XEN) CS=e008 DS=0000 ES=0000 FS=0000 GS=0000 SS=0000 TR=e040 (XEN) FSBase=0000000000000000 GSBase=0000000000000000 TRBase=ffff828c802a8b00
(XEN) GDTBase=ffff83007e9a3000 IDTBase=ffff83007e62e010 (XEN) CR0=0000000080050033 CR3=000000007cfdc000 CR4=00000000000026f0 (XEN) Sysenter RSP=ffff83007e4f7fd0 CS:RIP=e008:ffff828c801c7290 (XEN) Host PAT = 0x0000000000000000
(XEN) *** Control State ***
(XEN) PinBased=0000003f CPUBased=b6a1e7fe SecondaryExec=00000041 (XEN) EntryControls=000011ff ExitControls=0003efff
(XEN) ExceptionBitmap=00044080
(XEN) VMEntry: intr_info=80000b0b errcode=00001eac ilen=00000000 (XEN) VMExit: intr_info=00000000 errcode=00008000 ilen=00000000
(XEN) reason=80000021 qualification=00000000
(XEN) IDTVectoring: info=00000000 errcode=00000000
(XEN) TPR Threshold = 0x00
(XEN) EPT pointer = 0x0000000000000000
(XEN) Virtual processor ID = 0x0000
(XEN) **************************************
(XEN) domain_crash called from vmx.c:2218
(XEN) Domain 1 (vcpu#0) crashed on cpu#1:
(XEN) ----[ Xen-3.4.0-rc3-pre x86_64 debug=n Not tainted ]----
(XEN) CPU: 1
(XEN) RIP: 0060:[<000000000000002a>]
(XEN) RFLAGS: 0000000000023202 CONTEXT: hvm guest
(XEN) rax: 0000000000000007 rbx: 0000000000001490 rcx:
0000000000000000
(XEN) rdx: 0000000000001da8 rsi: 0000000000000000 rdi:
0000000000000000
(XEN) rbp: 0000000000008ebf rsp: 0000000000000080 r8:
0000000000000000

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

(XEN) r9: 0000000000000000 r10: 0000000000000000 r11:
0000000000000000
(XEN) r12: 0000000000000000 r13: 0000000000000000 r14:
0000000000000000
(XEN) r15: 0000000000000000 cr0: 0000000080000019 cr4:
0000000000000000
(XEN) cr3: 0000000001443000 cr2: 0000000000000000
(XEN) ds: 0068 es: 0068 fs: 0068 gs: 0068 ss: 0070 cs:

0060

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Could it be, that the real mode emulation code has a bug? What does

this

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

error means?

Tom

2009/4/22 Keir Fraser <[email protected]<mailto:[email protected]>> On 22/04/2009 12:18, "Tom Rotenberg" <[email protected]<mailto:[email protected]>> wrote:

Quoted 38 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Keir,

I have applied your patch, and it seemed to work. However, the

domain

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

still
crashes, and now it looks like it's because of the 'LTR'

instruction.

Quoted 28 lines
Quoted 27 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 7 lines

Try the attached patch. It replaces the one I sent last time, and emulates
both LLDT and LTR.

-- Keir

Content-Description: ATT00001.txt

Quoted 4 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

Quoted 7 lines
Quoted 5 lines
Quoted 4 lines

--
Tim Deegan <[email protected]>
Principal Software Engineer, Citrix Systems (R&D) Ltd. [Company #02300071, SL9 0DZ, UK.]

--
Tim Deegan <[email protected]>
Principal Software Engineer, Citrix Systems (R&D) Ltd. [Company #02300071, SL9 0DZ, UK.]

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#15 lore raw

That should do it.

K.

Quoted 223 lines · Tom Rotenberg

Keir,
Just to make sure, i am using the following patch, in order to disable the vm86 acceleration:

diff -r cdc044f665dc xen/arch/x86/hvm/vmx/vmx.c

xen/arch/x86/hvm/vmx/vmx.c    Wed Apr 22 17:03:20 2009 +0300 renamed from xen/arch/x86/hvm/vmx/vmx.c    Wed Apr 22 11:26:37 2009 +0100 +0 -0
@@ -829,7 +829,7 @@


         if ( seg == x86_seg_tr )
         {
-            if ( v->domain->arch.hvm_domain.params[HVM_PARAM_VM86_TSS] ) +            if (0)
             {
                 sel = 0;
                 attr = vm86_tr_attr;

Is this OK?

Tom

2009/4/22 Keir Fraser <[email protected]>

Quoted 200 lines

Yes, the safest way to be sure is probably to replace the if() statement in vmx_set_segment_register() that tests HVM_PARAM_VM86_TSS with if(0). That is the only place in Xen that checks HVM_PARAM_VM86_TSS. Then you can re-build/install Xen and be sure that vm86 accel must be disabled.

 -- Keir

Quoted 189 lines · Tom Rotenberg

So, do u suggest, that i will set HVM_PARAM_VM86_TSS to 0, and re-check it?

2009/4/22 Tim Deegan <[email protected]>

Quoted 185 lines
Quoted 9 lines · Keir Fraser

It could be an issue with the vm86 acceleration, possibly. I'm pretty sure the guest would have to IRET from protected mode to enter vm86 mode itself,
and we don't emulate that. Tim: what would we need to do to disable the vm86
acceleration for testing purposes? You suggested not setting VM86_TSS param
from hvmloader, but I couldn't convince myself what effect that would actually have as the logic in Xen is non-trivial.

Yes; if HVM_PARAM_VM86_TSS is zero, vmx_set_segment_register() will always set the tss bit in the bitmap of segments that aren't safe to enter VM86 with.

Tim.

Quoted 163 lines

 -- Keir

Quoted 156 lines · Tom Rotenberg

Tim,

so what does it mean? could it be that we have a bug in the real mode emulation, which causes the segment state to be invalid (maybe it's because
of
a bug in the patch that Keir made for me, which emulated the LLDT, and the
LTR
instructions)?

Keir suggested to trace back where the problem (segment state) occured, and
from there to try and find the bug which caused it. Do u have any better suggestion for solving this?

Tom

2009/4/22 Tim Deegan <[email protected]>

Quoted 136 lines
Quoted 15 lines · Tom Rotenberg

Keir,

I have tried your latest patch, and it looks like now it passes the emulation problem. However,  now the domain crashes with the following error:

(XEN) HVM1: Booting from 0000:7c00
(XEN) Failed vm entry (exit reason 0x80000021) caused by invalid guest state
(0).
(XEN) ************* VMCS Area **************
(XEN) *** Guest State ***
(XEN) CR0: actual=0x0000000080010039, shadow=0x0000000080000019, gh_mask=ffffffffffffffff
(XEN) CR4: actual=0x0000000000002060, shadow=0x0000000000000000,

Quoted 8 lines

gh_mask=ffffffffffffffff
(XEN) CR3: actual=0x000000000a213a20, target_count=0 (XEN)      target0=0000000000000000, target1=0000000000000000 (XEN)      target2=0000000000000000, target3=0000000000000000 (XEN) RSP = 0x0000000000000080 (0x0000000000000080)  RIP = 0x000000000000002a (0x000000000000002a)
(XEN) RFLAGS=0x0000000000023202 (0x0000000000023202)  DR7 = 0x0000000000000400

Looks like we're trying to VMENTER in virtual 8086 mode but without tidying up the segment state.  That could either be the guest entering virtual 8086 mode itself or Xen entering vitrual 8086 mode to emulate real mode, but Xen is always careful to make the segment state agree with Intel's rather strict requrements when it does that.

Tim.

Quoted 84 lines

(XEN) Sysenter RSP=0000000000000000 CS:RIP=0000:0000000000000000 (XEN) CS: sel=0x0060, attr=0x0c09b, limit=0xffffffff, base=0x0000000000200000
(XEN) DS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) SS: sel=0x0070, attr=0x0c093, limit=0xfc000fff, base=0x000000000020ba62
(XEN) ES: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) FS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) GS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) GDTR:                           limit=0x00001dd8, base=0x0000000000200000
(XEN) LDTR: sel=0x0000, attr=0x1c000, limit=0xffffffff, base=0x0000000000000000
(XEN) IDTR:                           limit=0x00000188, base=0x0000000000201df0
(XEN) TR: sel=0x0058, attr=0x0008b, limit=0x0000ffff, base=0x0000000000201ff2
(XEN) Guest PAT = 0x0000000000000000
(XEN) TSC Offset = ffffffe4920110b7
(XEN) DebugCtl=0000000000000000 DebugExceptions=0000000000000000 (XEN) Interruptibility=0001 ActivityState=0000
(XEN) *** Host State ***
(XEN) RSP = 0xffff83007e4f7fa0  RIP = 0xffff828c8019aa20 (XEN) CS=e008 DS=0000 ES=0000 FS=0000 GS=0000 SS=0000 TR=e040 (XEN) FSBase=0000000000000000 GSBase=0000000000000000 TRBase=ffff828c802a8b00
(XEN) GDTBase=ffff83007e9a3000 IDTBase=ffff83007e62e010 (XEN) CR0=0000000080050033 CR3=000000007cfdc000 CR4=00000000000026f0 (XEN) Sysenter RSP=ffff83007e4f7fd0 CS:RIP=e008:ffff828c801c7290 (XEN) Host PAT = 0x0000000000000000
(XEN) *** Control State ***
(XEN) PinBased=0000003f CPUBased=b6a1e7fe SecondaryExec=00000041 (XEN) EntryControls=000011ff ExitControls=0003efff
(XEN) ExceptionBitmap=00044080
(XEN) VMEntry: intr_info=80000b0b errcode=00001eac ilen=00000000 (XEN) VMExit: intr_info=00000000 errcode=00008000 ilen=00000000 (XEN)         reason=80000021 qualification=00000000
(XEN) IDTVectoring: info=00000000 errcode=00000000
(XEN) TPR Threshold = 0x00
(XEN) EPT pointer = 0x0000000000000000
(XEN) Virtual processor ID = 0x0000
(XEN) **************************************
(XEN) domain_crash called from vmx.c:2218
(XEN) Domain 1 (vcpu#0) crashed on cpu#1:
(XEN) ----[ Xen-3.4.0-rc3-pre  x86_64  debug=n  Not tainted ]---- (XEN) CPU:    1
(XEN) RIP:    0060:[<000000000000002a>]
(XEN) RFLAGS: 0000000000023202   CONTEXT: hvm guest
(XEN) rax: 0000000000000007   rbx: 0000000000001490   rcx:
0000000000000000
(XEN) rdx: 0000000000001da8   rsi: 0000000000000000   rdi:
0000000000000000
(XEN) rbp: 0000000000008ebf   rsp: 0000000000000080   r8:
 0000000000000000
(XEN) r9:  0000000000000000   r10: 0000000000000000   r11:
0000000000000000
(XEN) r12: 0000000000000000   r13: 0000000000000000   r14:
0000000000000000
(XEN) r15: 0000000000000000   cr0: 0000000080000019   cr4:
0000000000000000
(XEN) cr3: 0000000001443000   cr2: 0000000000000000
(XEN) ds: 0068   es: 0068   fs: 0068   gs: 0068   ss: 0070   cs: 0060

Could it be, that the real mode emulation code has a bug? What does this
error means?

Tom

2009/4/22 Keir Fraser <[email protected]<mailto:[email protected]>>

Quoted 5 lines · On 22/04/2009 12:18, "Tom Rotenberg" <[email protected]<mailto:tom.rotenb…

Keir,

I have applied your patch, and it seemed to work. However, the domain still
crashes, and now it looks like it's because of the 'LTR' instruction.

Quoted 6 lines

Try the attached patch. It replaces the one I sent last time, and emulates
both LLDT and LTR.

 -- Keir

Content-Description: ATT00001.txt

Quoted 4 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

--
Tim Deegan <[email protected]>
Principal Software Engineer, Citrix Systems (R&D) Ltd. [Company #02300071, SL9 0DZ, UK.]

--
Tim Deegan <[email protected]>
Principal Software Engineer, Citrix Systems (R&D) Ltd. [Company #02300071, SL9 0DZ, UK.]

#16 lore raw

Well, just tried this patch, and it doesn't seem to work. I get the following error:

(XEN) HVM1: Booting from 0000:7c00
(XEN) Failed vm entry (exit reason 0x80000021) caused by invalid guest state (0).
(XEN) ************* VMCS Area **************
(XEN) *** Guest State ***
(XEN) CR0: actual=0x0000000080010039, shadow=0x0000000080000019, gh_mask=ffffffffffffffff
(XEN) CR4: actual=0x0000000000002060, shadow=0x0000000000000000, gh_mask=ffffffffffffffff
(XEN) CR3: actual=0x000000000a22fa20, target_count=0
(XEN) target0=0000000000000000, target1=0000000000000000
(XEN) target2=0000000000000000, target3=0000000000000000
(XEN) RSP = 0x0000000000000080 (0x0000000000000080) RIP = 0x000000000000002a (0x000000000000002a)
(XEN) RFLAGS=0x0000000000023202 (0x0000000000023202) DR7 = 0x0000000000000400
(XEN) Sysenter RSP=0000000000000000 CS:RIP=0000:0000000000000000 (XEN) CS: sel=0x0060, attr=0x0c09b, limit=0xffffffff, base=0x0000000000200000
(XEN) DS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) SS: sel=0x0070, attr=0x0c093, limit=0xfc000fff, base=0x000000000020ba62
(XEN) ES: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) FS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) GS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) GDTR: limit=0x00001dd8,
base=0x0000000000200000
(XEN) LDTR: sel=0x0000, attr=0x1c000, limit=0xffffffff, base=0x0000000000000000
(XEN) IDTR: limit=0x00000188,
base=0x0000000000201df0
(XEN) TR: sel=0x0058, attr=0x0008b, limit=0x0000ffff, base=0x0000000000201ff2
(XEN) Guest PAT = 0x0000000000000000
(XEN) TSC Offset = ffffffe2242f086e
(XEN) DebugCtl=0000000000000000 DebugExceptions=0000000000000000 (XEN) Interruptibility=0001 ActivityState=0000
(XEN) *** Host State ***
(XEN) RSP = 0xffff83007e4f7fa0 RIP = 0xffff828c8019aa20
(XEN) CS=e008 DS=0000 ES=0000 FS=0000 GS=0000 SS=0000 TR=e040 (XEN) FSBase=0000000000000000 GSBase=0000000000000000 TRBase=ffff828c802a8b00
(XEN) GDTBase=ffff83007e9a3000 IDTBase=ffff83007e62e010
(XEN) CR0=0000000080050033 CR3=000000007cfd8000 CR4=00000000000026f0 (XEN) Sysenter RSP=ffff83007e4f7fd0 CS:RIP=e008:ffff828c801c7290 (XEN) Host PAT = 0x0000000000000000
(XEN) *** Control State ***
(XEN) PinBased=0000003f CPUBased=b6a1e7fe SecondaryExec=00000041 (XEN) EntryControls=000011ff ExitControls=0003efff
(XEN) ExceptionBitmap=00044080
(XEN) VMEntry: intr_info=80000b0b errcode=00001eac ilen=00000000 (XEN) VMExit: intr_info=00000000 errcode=00008000 ilen=00000000
(XEN) reason=80000021 qualification=00000000
(XEN) IDTVectoring: info=00000000 errcode=00000000
(XEN) TPR Threshold = 0x00
(XEN) EPT pointer = 0x0000000000000000
(XEN) Virtual processor ID = 0x0000
(XEN) **************************************
(XEN) domain_crash called from vmx.c:2218
(XEN) Domain 1 (vcpu#0) crashed on cpu#1:
(XEN) ----[ Xen-3.4.0-rc3-pre x86_64 debug=n Not tainted ]----
(XEN) CPU: 1
(XEN) RIP: 0060:[<000000000000002a>]
(XEN) RFLAGS: 0000000000023202 CONTEXT: hvm guest

(XEN) rax: 0000000000000007   rbx: 0000000000001490   rcx: 0000000000000000
(XEN) rdx: 0000000000001da8   rsi: 0000000000000000   rdi: 0000000000000000
(XEN) rbp: 0000000000008ebf   rsp: 0000000000000080   r8:  0000000000000000
(XEN) r9:  0000000000000000   r10: 0000000000000000   r11: 0000000000000000
(XEN) r12: 0000000000000000   r13: 0000000000000000   r14: 0000000000000000
(XEN) r15: 0000000000000000   cr0: 0000000080000019   cr4: 0000000000000000
(XEN) cr3: 0000000001443000   cr2: 0000000000000000

(XEN) ds: 0068 es: 0068 fs: 0068 gs: 0068 ss: 0070 cs: 0060

Any ideas?

Tom

2009/4/22 Keir Fraser <[email protected]>

Quoted 214 lines

That should do it.

K.

Quoted 2 lines · Tom Rotenberg

Keir,
Just to make sure, i am using the following patch, in order to disable

the

Quoted 15 lines

vm86 acceleration:

diff -r cdc044f665dc xen/arch/x86/hvm/vmx/vmx.c

xen/arch/x86/hvm/vmx/vmx.c Wed Apr 22 17:03:20 2009 +0300 renamed from xen/arch/x86/hvm/vmx/vmx.c Wed Apr 22 11:26:37 2009 +0100 +1 -1
@@ -829,7 +829,7 @@
 
         if ( seg == x86_seg_tr )
         {
-            if ( v->domain->arch.hvm_domain.params[HVM_PARAM_VM86_TSS] )
+            if (0)
             {
                 sel = 0;
                 attr = vm86_tr_attr;
Quoted 6 lines

Is this OK?

Tom

2009/4/22 Keir Fraser <[email protected]>

Quoted 1 line

Yes, the safest way to be sure is probably to replace the if() statement

in

Quoted 1 line
Quoted 1 line

vmx_set_segment_register() that tests HVM_PARAM_VM86_TSS with if(0).

That is

Quoted 8 lines
Quoted 8 lines

the only place in Xen that checks HVM_PARAM_VM86_TSS. Then you can re-build/install Xen and be sure that vm86 accel must be disabled.

-- Keir

Quoted 1 line · Tom Rotenberg

So, do u suggest, that i will set HVM_PARAM_VM86_TSS to 0, and re-check

it?

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

2009/4/22 Tim Deegan <[email protected]>

Quoted 2 lines
Quoted 1 line · Keir Fraser

It could be an issue with the vm86 acceleration, possibly. I'm pretty

sure

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

the guest would have to IRET from protected mode to enter vm86 mode itself,
and we don't emulate that. Tim: what would we need to do to disable

the

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 5 lines

vm86
acceleration for testing purposes? You suggested not setting VM86_TSS param
from hvmloader, but I couldn't convince myself what effect that would actually have as the logic in Xen is non-trivial.

Yes; if HVM_PARAM_VM86_TSS is zero, vmx_set_segment_register() will always set the tss bit in the bitmap of segments that aren't safe to enter VM86 with.

Tim.

Quoted 4 lines

-- Keir

On 22/04/2009 14:23, "Tom Rotenberg" <[email protected]>

Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Tim,

so what does it mean? could it be that we have a bug in the real

mode

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

emulation, which causes the segment state to be invalid (maybe it's because
of
a bug in the patch that Keir made for me, which emulated the LLDT,

and

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

the
LTR
instructions)?

Keir suggested to trace back where the problem (segment state)

occured,

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

and
from there to try and find the bug which caused it. Do u have any

better

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

suggestion for solving this?

Tom

2009/4/22 Tim Deegan <[email protected]>

Quoted 4 lines
Quoted 3 lines · Tom Rotenberg

Keir,

I have tried your latest patch, and it looks like now it passes

the

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

emulation problem. However, now the domain crashes with the

following

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

error:

(XEN) HVM1: Booting from 0000:7c00
(XEN) Failed vm entry (exit reason 0x80000021) caused by invalid

guest

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 15 lines

state
(0).
(XEN) ************* VMCS Area **************
(XEN) *** Guest State ***
(XEN) CR0: actual=0x0000000080010039, shadow=0x0000000080000019, gh_mask=ffffffffffffffff
(XEN) CR4: actual=0x0000000000002060, shadow=0x0000000000000000, gh_mask=ffffffffffffffff
(XEN) CR3: actual=0x000000000a213a20, target_count=0
(XEN) target0=0000000000000000, target1=0000000000000000
(XEN) target2=0000000000000000, target3=0000000000000000
(XEN) RSP = 0x0000000000000080 (0x0000000000000080) RIP = 0x000000000000002a (0x000000000000002a)
(XEN) RFLAGS=0x0000000000023202 (0x0000000000023202) DR7 = 0x0000000000000400

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Looks like we're trying to VMENTER in virtual 8086 mode but without tidying up the segment state. That could either be the guest

entering

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

virtual 8086 mode itself or Xen entering vitrual 8086 mode to

emulate

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

real mode, but Xen is always careful to make the segment state

agree

Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
Quoted 29 lines

with Intel's rather strict requrements when it does that.

Tim.

Quoted 24 lines

(XEN) Sysenter RSP=0000000000000000 CS:RIP=0000:0000000000000000 (XEN) CS: sel=0x0060, attr=0x0c09b, limit=0xffffffff, base=0x0000000000200000
(XEN) DS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) SS: sel=0x0070, attr=0x0c093, limit=0xfc000fff, base=0x000000000020ba62
(XEN) ES: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) FS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) GS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) GDTR: limit=0x00001dd8,
base=0x0000000000200000
(XEN) LDTR: sel=0x0000, attr=0x1c000, limit=0xffffffff, base=0x0000000000000000
(XEN) IDTR: limit=0x00000188,
base=0x0000000000201df0
(XEN) TR: sel=0x0058, attr=0x0008b, limit=0x0000ffff, base=0x0000000000201ff2
(XEN) Guest PAT = 0x0000000000000000
(XEN) TSC Offset = ffffffe4920110b7
(XEN) DebugCtl=0000000000000000 DebugExceptions=0000000000000000

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

(XEN) Interruptibility=0001 ActivityState=0000 (XEN) *** Host State ***
(XEN) RSP = 0xffff83007e4f7fa0 RIP = 0xffff828c8019aa20 (XEN) CS=e008 DS=0000 ES=0000 FS=0000 GS=0000 SS=0000 TR=e040 (XEN) FSBase=0000000000000000 GSBase=0000000000000000 TRBase=ffff828c802a8b00
(XEN) GDTBase=ffff83007e9a3000 IDTBase=ffff83007e62e010 (XEN) CR0=0000000080050033 CR3=000000007cfdc000

CR4=00000000000026f0

Quoted 26 lines
Quoted 26 lines
Quoted 26 lines
Quoted 26 lines
Quoted 26 lines
Quoted 26 lines
Quoted 26 lines
Quoted 26 lines

(XEN) Sysenter RSP=ffff83007e4f7fd0 CS:RIP=e008:ffff828c801c7290 (XEN) Host PAT = 0x0000000000000000
(XEN) *** Control State ***
(XEN) PinBased=0000003f CPUBased=b6a1e7fe SecondaryExec=00000041 (XEN) EntryControls=000011ff ExitControls=0003efff (XEN) ExceptionBitmap=00044080
(XEN) VMEntry: intr_info=80000b0b errcode=00001eac ilen=00000000 (XEN) VMExit: intr_info=00000000 errcode=00008000 ilen=00000000
(XEN) reason=80000021 qualification=00000000
(XEN) IDTVectoring: info=00000000 errcode=00000000 (XEN) TPR Threshold = 0x00
(XEN) EPT pointer = 0x0000000000000000
(XEN) Virtual processor ID = 0x0000
(XEN) **************************************
(XEN) domain_crash called from vmx.c:2218
(XEN) Domain 1 (vcpu#0) crashed on cpu#1:
(XEN) ----[ Xen-3.4.0-rc3-pre x86_64 debug=n Not tainted ]----
(XEN) CPU: 1
(XEN) RIP: 0060:[<000000000000002a>]
(XEN) RFLAGS: 0000000000023202 CONTEXT: hvm guest
(XEN) rax: 0000000000000007 rbx: 0000000000001490 rcx:
0000000000000000
(XEN) rdx: 0000000000001da8 rsi: 0000000000000000 rdi:
0000000000000000
(XEN) rbp: 0000000000008ebf rsp: 0000000000000080 r8:
0000000000000000

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

(XEN) r9: 0000000000000000 r10: 0000000000000000 r11:
0000000000000000
(XEN) r12: 0000000000000000 r13: 0000000000000000 r14:
0000000000000000
(XEN) r15: 0000000000000000 cr0: 0000000080000019 cr4:
0000000000000000
(XEN) cr3: 0000000001443000 cr2: 0000000000000000
(XEN) ds: 0068 es: 0068 fs: 0068 gs: 0068 ss: 0070 cs:

0060

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Could it be, that the real mode emulation code has a bug? What

does

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

this
error means?

Tom

2009/4/22 Keir Fraser <[email protected]<mailto:[email protected]>> On 22/04/2009 12:18, "Tom Rotenberg" <[email protected]<mailto:[email protected]>> wrote:

Quoted 41 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Keir,

I have applied your patch, and it seemed to work. However, the

domain

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

still
crashes, and now it looks like it's because of the 'LTR'

instruction.

Quoted 31 lines
Quoted 30 lines
Quoted 28 lines
Quoted 27 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 7 lines

Try the attached patch. It replaces the one I sent last time, and emulates
both LLDT and LTR.

-- Keir

Content-Description: ATT00001.txt

Quoted 4 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

Quoted 7 lines
Quoted 5 lines
Quoted 4 lines

--
Tim Deegan <[email protected]>
Principal Software Engineer, Citrix Systems (R&D) Ltd. [Company #02300071, SL9 0DZ, UK.]

--
Tim Deegan <[email protected]>
Principal Software Engineer, Citrix Systems (R&D) Ltd. [Company #02300071, SL9 0DZ, UK.]

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#17 lore raw

Then it probably is a mis-emulation somewhere down the line. Unfortunately that could be hard to track down, even if we had PointSec software to hand, which we do not.

-- Keir

Quoted 319 lines · Tom Rotenberg

Well, just tried this patch, and it doesn't seem to work. I get the following error:

(XEN) HVM1: Booting from 0000:7c00
(XEN) Failed vm entry (exit reason 0x80000021) caused by invalid guest state (0).
(XEN) ************* VMCS Area **************
(XEN) *** Guest State ***
(XEN) CR0: actual=0x0000000080010039, shadow=0x0000000080000019, gh_mask=ffffffffffffffff
(XEN) CR4: actual=0x0000000000002060, shadow=0x0000000000000000, gh_mask=ffffffffffffffff
(XEN) CR3: actual=0x000000000a22fa20, target_count=0
(XEN)      target0=0000000000000000, target1=0000000000000000 (XEN)      target2=0000000000000000, target3=0000000000000000 (XEN) RSP = 0x0000000000000080 (0x0000000000000080)  RIP = 0x000000000000002a (0x000000000000002a)
(XEN) RFLAGS=0x0000000000023202 (0x0000000000023202)  DR7 = 0x0000000000000400 (XEN) Sysenter RSP=0000000000000000 CS:RIP=0000:0000000000000000 (XEN) CS: sel=0x0060, attr=0x0c09b, limit=0xffffffff, base=0x0000000000200000 (XEN) DS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000 (XEN) SS: sel=0x0070, attr=0x0c093, limit=0xfc000fff, base=0x000000000020ba62 (XEN) ES: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000 (XEN) FS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000 (XEN) GS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000 (XEN) GDTR:                           limit=0x00001dd8, base=0x0000000000200000
(XEN) LDTR: sel=0x0000, attr=0x1c000, limit=0xffffffff, base=0x0000000000000000
(XEN) IDTR:                           limit=0x00000188, base=0x0000000000201df0
(XEN) TR: sel=0x0058, attr=0x0008b, limit=0x0000ffff, base=0x0000000000201ff2 (XEN) Guest PAT = 0x0000000000000000
(XEN) TSC Offset = ffffffe2242f086e
(XEN) DebugCtl=0000000000000000 DebugExceptions=0000000000000000 (XEN) Interruptibility=0001 ActivityState=0000
(XEN) *** Host State ***
(XEN) RSP = 0xffff83007e4f7fa0  RIP = 0xffff828c8019aa20
(XEN) CS=e008 DS=0000 ES=0000 FS=0000 GS=0000 SS=0000 TR=e040 (XEN) FSBase=0000000000000000 GSBase=0000000000000000 TRBase=ffff828c802a8b00 (XEN) GDTBase=ffff83007e9a3000 IDTBase=ffff83007e62e010
(XEN) CR0=0000000080050033 CR3=000000007cfd8000 CR4=00000000000026f0 (XEN) Sysenter RSP=ffff83007e4f7fd0 CS:RIP=e008:ffff828c801c7290 (XEN) Host PAT = 0x0000000000000000
(XEN) *** Control State ***
(XEN) PinBased=0000003f CPUBased=b6a1e7fe SecondaryExec=00000041 (XEN) EntryControls=000011ff ExitControls=0003efff
(XEN) ExceptionBitmap=00044080
(XEN) VMEntry: intr_info=80000b0b errcode=00001eac ilen=00000000 (XEN) VMExit: intr_info=00000000 errcode=00008000 ilen=00000000 (XEN)         reason=80000021 qualification=00000000
(XEN) IDTVectoring: info=00000000 errcode=00000000
(XEN) TPR Threshold = 0x00
(XEN) EPT pointer = 0x0000000000000000
(XEN) Virtual processor ID = 0x0000
(XEN) **************************************
(XEN) domain_crash called from vmx.c:2218
(XEN) Domain 1 (vcpu#0) crashed on cpu#1:
(XEN) ----[ Xen-3.4.0-rc3-pre  x86_64  debug=n  Not tainted ]---- (XEN) CPU:    1
(XEN) RIP:    0060:[<000000000000002a>]
(XEN) RFLAGS: 0000000000023202   CONTEXT: hvm guest
(XEN) rax: 0000000000000007   rbx: 0000000000001490   rcx: 0000000000000000 (XEN) rdx: 0000000000001da8   rsi: 0000000000000000   rdi: 0000000000000000 (XEN) rbp: 0000000000008ebf   rsp: 0000000000000080   r8:  0000000000000000 (XEN) r9:  0000000000000000   r10: 0000000000000000   r11: 0000000000000000 (XEN) r12: 0000000000000000   r13: 0000000000000000   r14: 0000000000000000 (XEN) r15: 0000000000000000   cr0: 0000000080000019   cr4: 0000000000000000 (XEN) cr3: 0000000001443000   cr2: 0000000000000000
(XEN) ds: 0068   es: 0068   fs: 0068   gs: 0068   ss: 0070   cs: 0060

Any ideas?

Tom

2009/4/22 Keir Fraser <[email protected]>

Quoted 240 lines

That should do it.

 K.

Quoted 231 lines · Tom Rotenberg

Keir,
Just to make sure, i am using the following patch, in order to disable the vm86 acceleration:

diff -r cdc044f665dc xen/arch/x86/hvm/vmx/vmx.c

xen/arch/x86/hvm/vmx/vmx.c    Wed Apr 22 17:03:20 2009 +0300 renamed from xen/arch/x86/hvm/vmx/vmx.c    Wed Apr 22 11:26:37 2009 +0100 +0 -0
@@ -829,7 +829,7 @@


         if ( seg == x86_seg_tr )
         {
-            if ( v->domain->arch.hvm_domain.params[HVM_PARAM_VM86_TSS] ) +            if (0)
             {
                 sel = 0;
                 attr = vm86_tr_attr;

Is this OK?

Tom

2009/4/22 Keir Fraser <[email protected]>

Quoted 208 lines

Yes, the safest way to be sure is probably to replace the if() statement in vmx_set_segment_register() that tests HVM_PARAM_VM86_TSS with if(0). That is
the only place in Xen that checks HVM_PARAM_VM86_TSS. Then you can re-build/install Xen and be sure that vm86 accel must be disabled.

 -- Keir

Quoted 196 lines · Tom Rotenberg

So, do u suggest, that i will set HVM_PARAM_VM86_TSS to 0, and re-check it?

2009/4/22 Tim Deegan <[email protected]>

Quoted 191 lines
Quoted 10 lines · Keir Fraser

It could be an issue with the vm86 acceleration, possibly. I'm pretty sure
the guest would have to IRET from protected mode to enter vm86 mode itself,
and we don't emulate that. Tim: what would we need to do to disable the vm86
acceleration for testing purposes? You suggested not setting VM86_TSS param
from hvmloader, but I couldn't convince myself what effect that would actually have as the logic in Xen is non-trivial.

Yes; if HVM_PARAM_VM86_TSS is zero, vmx_set_segment_register() will always set the tss bit in the bitmap of segments that aren't safe to enter VM86 with.

Tim.

Quoted 168 lines

 -- Keir

Quoted 161 lines · Tom Rotenberg

Tim,

so what does it mean? could it be that we have a bug in the real mode emulation, which causes the segment state to be invalid (maybe it's because
of
a bug in the patch that Keir made for me, which emulated the LLDT, and the
LTR
instructions)?

Keir suggested to trace back where the problem (segment state) occured, and
from there to try and find the bug which caused it. Do u have any better
suggestion for solving this?

Tom

2009/4/22 Tim Deegan <[email protected]>

Quoted 140 lines
Quoted 17 lines · Tom Rotenberg

Keir,

I have tried your latest patch, and it looks like now it passes the emulation problem. However,  now the domain crashes with the following
error:

(XEN) HVM1: Booting from 0000:7c00
(XEN) Failed vm entry (exit reason 0x80000021) caused by invalid guest
state
(0).
(XEN) ************* VMCS Area **************
(XEN) *** Guest State ***
(XEN) CR0: actual=0x0000000080010039, shadow=0x0000000080000019, gh_mask=ffffffffffffffff
(XEN) CR4: actual=0x0000000000002060, shadow=0x0000000000000000,

Quoted 8 lines

gh_mask=ffffffffffffffff
(XEN) CR3: actual=0x000000000a213a20, target_count=0 (XEN)      target0=0000000000000000, target1=0000000000000000 (XEN)      target2=0000000000000000, target3=0000000000000000 (XEN) RSP = 0x0000000000000080 (0x0000000000000080)  RIP = 0x000000000000002a (0x000000000000002a)
(XEN) RFLAGS=0x0000000000023202 (0x0000000000023202)  DR7 = 0x0000000000000400

Looks like we're trying to VMENTER in virtual 8086 mode but without tidying up the segment state.  That could either be the guest entering virtual 8086 mode itself or Xen entering vitrual 8086 mode to emulate real mode, but Xen is always careful to make the segment state agree with Intel's rather strict requrements when it does that.

Tim.

Quoted 86 lines

(XEN) Sysenter RSP=0000000000000000 CS:RIP=0000:0000000000000000 (XEN) CS: sel=0x0060, attr=0x0c09b, limit=0xffffffff, base=0x0000000000200000
(XEN) DS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) SS: sel=0x0070, attr=0x0c093, limit=0xfc000fff, base=0x000000000020ba62
(XEN) ES: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) FS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) GS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) GDTR:                           limit=0x00001dd8, base=0x0000000000200000
(XEN) LDTR: sel=0x0000, attr=0x1c000, limit=0xffffffff, base=0x0000000000000000
(XEN) IDTR:                           limit=0x00000188, base=0x0000000000201df0
(XEN) TR: sel=0x0058, attr=0x0008b, limit=0x0000ffff, base=0x0000000000201ff2
(XEN) Guest PAT = 0x0000000000000000
(XEN) TSC Offset = ffffffe4920110b7
(XEN) DebugCtl=0000000000000000 DebugExceptions=0000000000000000 (XEN) Interruptibility=0001 ActivityState=0000
(XEN) *** Host State ***
(XEN) RSP = 0xffff83007e4f7fa0  RIP = 0xffff828c8019aa20 (XEN) CS=e008 DS=0000 ES=0000 FS=0000 GS=0000 SS=0000 TR=e040 (XEN) FSBase=0000000000000000 GSBase=0000000000000000 TRBase=ffff828c802a8b00
(XEN) GDTBase=ffff83007e9a3000 IDTBase=ffff83007e62e010 (XEN) CR0=0000000080050033 CR3=000000007cfdc000 CR4=00000000000026f0 (XEN) Sysenter RSP=ffff83007e4f7fd0 CS:RIP=e008:ffff828c801c7290 (XEN) Host PAT = 0x0000000000000000
(XEN) *** Control State ***
(XEN) PinBased=0000003f CPUBased=b6a1e7fe SecondaryExec=00000041 (XEN) EntryControls=000011ff ExitControls=0003efff
(XEN) ExceptionBitmap=00044080
(XEN) VMEntry: intr_info=80000b0b errcode=00001eac ilen=00000000 (XEN) VMExit: intr_info=00000000 errcode=00008000 ilen=00000000 (XEN)         reason=80000021 qualification=00000000
(XEN) IDTVectoring: info=00000000 errcode=00000000
(XEN) TPR Threshold = 0x00
(XEN) EPT pointer = 0x0000000000000000
(XEN) Virtual processor ID = 0x0000
(XEN) **************************************
(XEN) domain_crash called from vmx.c:2218
(XEN) Domain 1 (vcpu#0) crashed on cpu#1:
(XEN) ----[ Xen-3.4.0-rc3-pre  x86_64  debug=n  Not tainted ]---- (XEN) CPU:    1
(XEN) RIP:    0060:[<000000000000002a>]
(XEN) RFLAGS: 0000000000023202   CONTEXT: hvm guest
(XEN) rax: 0000000000000007   rbx: 0000000000001490   rcx:
0000000000000000
(XEN) rdx: 0000000000001da8   rsi: 0000000000000000   rdi:
0000000000000000
(XEN) rbp: 0000000000008ebf   rsp: 0000000000000080   r8:
 0000000000000000
(XEN) r9:  0000000000000000   r10: 0000000000000000   r11:
0000000000000000
(XEN) r12: 0000000000000000   r13: 0000000000000000   r14:
0000000000000000
(XEN) r15: 0000000000000000   cr0: 0000000080000019   cr4:
0000000000000000
(XEN) cr3: 0000000001443000   cr2: 0000000000000000
(XEN) ds: 0068   es: 0068   fs: 0068   gs: 0068   ss: 0070   cs: 0060

Could it be, that the real mode emulation code has a bug? What does this
error means?

Tom

2009/4/22 Keir Fraser <[email protected]<mailto:[email protected]>>

Quoted 7 lines · On 22/04/2009 12:18, "Tom Rotenberg" <[email protected]<mailto:tom.rotenb…

Keir,

I have applied your patch, and it seemed to work. However, the domain
still
crashes, and now it looks like it's because of the 'LTR' instruction.

Quoted 6 lines

Try the attached patch. It replaces the one I sent last time, and emulates
both LLDT and LTR.

 -- Keir

Content-Description: ATT00001.txt

Quoted 4 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

--
Tim Deegan <[email protected]>
Principal Software Engineer, Citrix Systems (R&D) Ltd. [Company #02300071, SL9 0DZ, UK.]

--
Tim Deegan <[email protected]>
Principal Software Engineer, Citrix Systems (R&D) Ltd. [Company #02300071, SL9 0DZ, UK.]

#18 lore raw

So, do u have any suggestion for me, on how to advance with this issue? should i debug the real mode emulation myself in order to track it down? will u be able top assist me in any way with this issue?

BTW - what is exactly the problem which causes this exception from the CPU? Tim mentioned something about segment state - can u please elaborate on this issue?

Tom

2009/4/22 Keir Fraser <[email protected]>

Quoted 329 lines

Then it probably is a mis-emulation somewhere down the line. Unfortunately that could be hard to track down, even if we had PointSec software to hand, which we do not.

-- Keir

Quoted 5 lines · Tom Rotenberg

Well, just tried this patch, and it doesn't seem to work. I get the following error:

(XEN) HVM1: Booting from 0000:7c00
(XEN) Failed vm entry (exit reason 0x80000021) caused by invalid guest

state

Quoted 11 lines

(0).
(XEN) ************* VMCS Area **************
(XEN) *** Guest State ***
(XEN) CR0: actual=0x0000000080010039, shadow=0x0000000080000019, gh_mask=ffffffffffffffff
(XEN) CR4: actual=0x0000000000002060, shadow=0x0000000000000000, gh_mask=ffffffffffffffff
(XEN) CR3: actual=0x000000000a22fa20, target_count=0
(XEN) target0=0000000000000000, target1=0000000000000000
(XEN) target2=0000000000000000, target3=0000000000000000
(XEN) RSP = 0x0000000000000080 (0x0000000000000080) RIP =

0x000000000000002a

Quoted 2 lines

(0x000000000000002a)
(XEN) RFLAGS=0x0000000000023202 (0x0000000000023202) DR7 =

0x0000000000000400

Quoted 2 lines

(XEN) Sysenter RSP=0000000000000000 CS:RIP=0000:0000000000000000 (XEN) CS: sel=0x0060, attr=0x0c09b, limit=0xffffffff,

base=0x0000000000200000

Quoted 1 line

(XEN) DS: sel=0x0068, attr=0x0c093, limit=0xffffffff,

base=0x0000000000200000

Quoted 1 line

(XEN) SS: sel=0x0070, attr=0x0c093, limit=0xfc000fff,

base=0x000000000020ba62

Quoted 1 line

(XEN) ES: sel=0x0068, attr=0x0c093, limit=0xffffffff,

base=0x0000000000200000

Quoted 1 line

(XEN) FS: sel=0x0068, attr=0x0c093, limit=0xffffffff,

base=0x0000000000200000

Quoted 1 line

(XEN) GS: sel=0x0068, attr=0x0c093, limit=0xffffffff,

base=0x0000000000200000

Quoted 7 lines

(XEN) GDTR: limit=0x00001dd8,
base=0x0000000000200000
(XEN) LDTR: sel=0x0000, attr=0x1c000, limit=0xffffffff, base=0x0000000000000000
(XEN) IDTR: limit=0x00000188,
base=0x0000000000201df0
(XEN) TR: sel=0x0058, attr=0x0008b, limit=0x0000ffff,

base=0x0000000000201ff2

Quoted 8 lines

(XEN) Guest PAT = 0x0000000000000000
(XEN) TSC Offset = ffffffe2242f086e
(XEN) DebugCtl=0000000000000000 DebugExceptions=0000000000000000 (XEN) Interruptibility=0001 ActivityState=0000
(XEN) *** Host State ***
(XEN) RSP = 0xffff83007e4f7fa0 RIP = 0xffff828c8019aa20 (XEN) CS=e008 DS=0000 ES=0000 FS=0000 GS=0000 SS=0000 TR=e040 (XEN) FSBase=0000000000000000 GSBase=0000000000000000

TRBase=ffff828c802a8b00

Quoted 15 lines

(XEN) GDTBase=ffff83007e9a3000 IDTBase=ffff83007e62e010 (XEN) CR0=0000000080050033 CR3=000000007cfd8000 CR4=00000000000026f0 (XEN) Sysenter RSP=ffff83007e4f7fd0 CS:RIP=e008:ffff828c801c7290 (XEN) Host PAT = 0x0000000000000000
(XEN) *** Control State ***
(XEN) PinBased=0000003f CPUBased=b6a1e7fe SecondaryExec=00000041 (XEN) EntryControls=000011ff ExitControls=0003efff
(XEN) ExceptionBitmap=00044080
(XEN) VMEntry: intr_info=80000b0b errcode=00001eac ilen=00000000 (XEN) VMExit: intr_info=00000000 errcode=00008000 ilen=00000000
(XEN) reason=80000021 qualification=00000000
(XEN) IDTVectoring: info=00000000 errcode=00000000
(XEN) TPR Threshold = 0x00
(XEN) EPT pointer = 0x0000000000000000
(XEN) Virtual processor ID = 0x0000

Quoted 8 lines

(XEN) **************************************
(XEN) domain_crash called from vmx.c:2218
(XEN) Domain 1 (vcpu#0) crashed on cpu#1:
(XEN) ----[ Xen-3.4.0-rc3-pre x86_64 debug=n Not tainted ]----
(XEN) CPU: 1
(XEN) RIP: 0060:[<000000000000002a>]
(XEN) RFLAGS: 0000000000023202 CONTEXT: hvm guest
(XEN) rax: 0000000000000007 rbx: 0000000000001490 rcx:

0000000000000000

Quoted 1 line

(XEN) rdx: 0000000000001da8 rsi: 0000000000000000 rdi:

0000000000000000

Quoted 1 line

(XEN) rbp: 0000000000008ebf rsp: 0000000000000080 r8:

0000000000000000

Quoted 1 line

(XEN) r9: 0000000000000000 r10: 0000000000000000 r11:

0000000000000000

Quoted 1 line

(XEN) r12: 0000000000000000 r13: 0000000000000000 r14:

0000000000000000

Quoted 1 line

(XEN) r15: 0000000000000000 cr0: 0000000080000019 cr4:

0000000000000000

Quoted 4 lines

(XEN) cr3: 0000000001443000 cr2: 0000000000000000
(XEN) ds: 0068 es: 0068 fs: 0068 gs: 0068 ss: 0070 cs: 0060

Quoted 15 lines

Any ideas?

Tom

2009/4/22 Keir Fraser <[email protected]>

Quoted 9 lines

That should do it.

K.

Quoted 2 lines · Tom Rotenberg

Keir,
Just to make sure, i am using the following patch, in order to disable

the

Quoted 10 lines
Quoted 10 lines

xen/arch/x86/hvm/vmx/vmx.c Wed Apr 22 17:03:20 2009 +0300 line 832

Quoted 10 lines

vm86 acceleration:

diff -r cdc044f665dc xen/arch/x86/hvm/vmx/vmx.c

xen/arch/x86/hvm/vmx/vmx.c Wed Apr 22 17:03:20 2009 +0300 renamed from xen/arch/x86/hvm/vmx/vmx.c Wed Apr 22 11:26:37 2009 +0100 +0 -1
@@ -829,7 +829,7 @@
 
         if ( seg == x86_seg_tr )
         {
-            if ( v->domain->arch.hvm_domain.params[HVM_PARAM_VM86_TSS]

)

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
xen/arch/x86/hvm/vmx/vmx.c Wed Apr 22 17:03:20 2009 +0300 renamed from xen/arch/x86/hvm/vmx/vmx.c Wed Apr 22 11:26:37 2009 +0100 +1 -0
+            if (0)
             {
                 sel = 0;
                 attr = vm86_tr_attr;

Is this OK?

Tom

2009/4/22 Keir Fraser <[email protected]>

Quoted 1 line

Yes, the safest way to be sure is probably to replace the if()

statement in

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

vmx_set_segment_register() that tests HVM_PARAM_VM86_TSS with if(0).

That

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

is
the only place in Xen that checks HVM_PARAM_VM86_TSS. Then you can re-build/install Xen and be sure that vm86 accel must be disabled.

-- Keir

Quoted 1 line · Tom Rotenberg

So, do u suggest, that i will set HVM_PARAM_VM86_TSS to 0, and

re-check

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

it?

2009/4/22 Tim Deegan <[email protected]>

Quoted 2 lines
Quoted 1 line · Keir Fraser

It could be an issue with the vm86 acceleration, possibly. I'm

pretty

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

sure
the guest would have to IRET from protected mode to enter vm86 mode itself,
and we don't emulate that. Tim: what would we need to do to disable

the

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

vm86
acceleration for testing purposes? You suggested not setting

VM86_TSS

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

param
from hvmloader, but I couldn't convince myself what effect that

would

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 1 line

actually have as the logic in Xen is non-trivial.

Yes; if HVM_PARAM_VM86_TSS is zero, vmx_set_segment_register() will always set the tss bit in the bitmap of segments that aren't safe to enter VM86 with.

Tim.

Quoted 4 lines

-- Keir

On 22/04/2009 14:23, "Tom Rotenberg" <[email protected]>

Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Tim,

so what does it mean? could it be that we have a bug in the real

mode

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

emulation, which causes the segment state to be invalid (maybe

it's

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

because
of
a bug in the patch that Keir made for me, which emulated the LLDT,

and

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

the
LTR
instructions)?

Keir suggested to trace back where the problem (segment state)

occured,

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

and
from there to try and find the bug which caused it. Do u have any better
suggestion for solving this?

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Tom

2009/4/22 Tim Deegan <[email protected]>

Quoted 4 lines
Quoted 3 lines · Tom Rotenberg

Keir,

I have tried your latest patch, and it looks like now it passes

the

Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
Quoted 22 lines

emulation problem. However, now the domain crashes with the following
error:

(XEN) HVM1: Booting from 0000:7c00
(XEN) Failed vm entry (exit reason 0x80000021) caused by invalid guest
state
(0).
(XEN) ************* VMCS Area **************
(XEN) *** Guest State ***
(XEN) CR0: actual=0x0000000080010039, shadow=0x0000000080000019, gh_mask=ffffffffffffffff
(XEN) CR4: actual=0x0000000000002060, shadow=0x0000000000000000, gh_mask=ffffffffffffffff
(XEN) CR3: actual=0x000000000a213a20, target_count=0
(XEN) target0=0000000000000000, target1=0000000000000000
(XEN) target2=0000000000000000, target3=0000000000000000
(XEN) RSP = 0x0000000000000080 (0x0000000000000080) RIP = 0x000000000000002a (0x000000000000002a)
(XEN) RFLAGS=0x0000000000023202 (0x0000000000023202) DR7 = 0x0000000000000400

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Looks like we're trying to VMENTER in virtual 8086 mode but

without

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

tidying up the segment state. That could either be the guest

entering

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

virtual 8086 mode itself or Xen entering vitrual 8086 mode to

emulate

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

real mode, but Xen is always careful to make the segment state

agree

Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
Quoted 29 lines

with Intel's rather strict requrements when it does that.

Tim.

Quoted 24 lines

(XEN) Sysenter RSP=0000000000000000 CS:RIP=0000:0000000000000000 (XEN) CS: sel=0x0060, attr=0x0c09b, limit=0xffffffff, base=0x0000000000200000
(XEN) DS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) SS: sel=0x0070, attr=0x0c093, limit=0xfc000fff, base=0x000000000020ba62
(XEN) ES: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) FS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) GS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) GDTR: limit=0x00001dd8,
base=0x0000000000200000
(XEN) LDTR: sel=0x0000, attr=0x1c000, limit=0xffffffff, base=0x0000000000000000
(XEN) IDTR: limit=0x00000188,
base=0x0000000000201df0
(XEN) TR: sel=0x0058, attr=0x0008b, limit=0x0000ffff, base=0x0000000000201ff2
(XEN) Guest PAT = 0x0000000000000000
(XEN) TSC Offset = ffffffe4920110b7
(XEN) DebugCtl=0000000000000000 DebugExceptions=0000000000000000

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

(XEN) Interruptibility=0001 ActivityState=0000 (XEN) *** Host State ***
(XEN) RSP = 0xffff83007e4f7fa0 RIP = 0xffff828c8019aa20 (XEN) CS=e008 DS=0000 ES=0000 FS=0000 GS=0000 SS=0000 TR=e040 (XEN) FSBase=0000000000000000 GSBase=0000000000000000 TRBase=ffff828c802a8b00
(XEN) GDTBase=ffff83007e9a3000 IDTBase=ffff83007e62e010 (XEN) CR0=0000000080050033 CR3=000000007cfdc000

CR4=00000000000026f0

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

(XEN) Sysenter RSP=ffff83007e4f7fd0 CS:RIP=e008:ffff828c801c7290 (XEN) Host PAT = 0x0000000000000000
(XEN) *** Control State ***
(XEN) PinBased=0000003f CPUBased=b6a1e7fe SecondaryExec=00000041 (XEN) EntryControls=000011ff ExitControls=0003efff (XEN) ExceptionBitmap=00044080
(XEN) VMEntry: intr_info=80000b0b errcode=00001eac ilen=00000000 (XEN) VMExit: intr_info=00000000 errcode=00008000 ilen=00000000
(XEN) reason=80000021 qualification=00000000

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

(XEN) IDTVectoring: info=00000000 errcode=00000000 (XEN) TPR Threshold = 0x00
(XEN) EPT pointer = 0x0000000000000000
(XEN) Virtual processor ID = 0x0000
(XEN) **************************************
(XEN) domain_crash called from vmx.c:2218
(XEN) Domain 1 (vcpu#0) crashed on cpu#1:
(XEN) ----[ Xen-3.4.0-rc3-pre x86_64 debug=n Not tainted

]----

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

(XEN) CPU: 1
(XEN) RIP: 0060:[<000000000000002a>]
(XEN) RFLAGS: 0000000000023202 CONTEXT: hvm guest
(XEN) rax: 0000000000000007 rbx: 0000000000001490 rcx:
0000000000000000
(XEN) rdx: 0000000000001da8 rsi: 0000000000000000 rdi:
0000000000000000
(XEN) rbp: 0000000000008ebf rsp: 0000000000000080 r8:
0000000000000000

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

(XEN) r9: 0000000000000000 r10: 0000000000000000 r11:
0000000000000000
(XEN) r12: 0000000000000000 r13: 0000000000000000 r14:
0000000000000000
(XEN) r15: 0000000000000000 cr0: 0000000080000019 cr4:
0000000000000000
(XEN) cr3: 0000000001443000 cr2: 0000000000000000
(XEN) ds: 0068 es: 0068 fs: 0068 gs: 0068 ss: 0070 cs:

0060

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Could it be, that the real mode emulation code has a bug? What

does

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

this
error means?

Tom

2009/4/22 Keir Fraser <[email protected]<mailto:[email protected]>> On 22/04/2009 12:18, "Tom Rotenberg" <[email protected]<mailto:[email protected]>>

Quoted 3 lines · wrote:
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Keir,

Quoted 43 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines

I have applied your patch, and it seemed to work. However, the domain
still
crashes, and now it looks like it's because of the 'LTR' instruction.

Try the attached patch. It replaces the one I sent last time,

and

Quoted 32 lines
Quoted 31 lines
Quoted 29 lines
Quoted 28 lines
Quoted 26 lines
Quoted 25 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 5 lines

emulates
both LLDT and LTR.

-- Keir

Content-Description: ATT00001.txt

Quoted 4 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

Quoted 7 lines
Quoted 5 lines
Quoted 4 lines

--
Tim Deegan <[email protected]>
Principal Software Engineer, Citrix Systems (R&D) Ltd. [Company #02300071, SL9 0DZ, UK.]

--
Tim Deegan <[email protected]>
Principal Software Engineer, Citrix Systems (R&D) Ltd. [Company #02300071, SL9 0DZ, UK.]

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#19 lore raw
Quoted 3 lines · Tom Rotenberg

So, do u have any suggestion for me, on how to advance with this issue? should i debug the real mode emulation myself in order to track it down? will u be able top assist me in any way with this issue?

If specific questions arise then certainly yes.

Quoted 3 lines

BTW - what is exactly the problem which causes this exception from the CPU? Tim mentioned something about segment state - can u please elaborate on this issue?

Bit 17 in EFLAGS is set, meaning the guest is in vm86 mode. In this mode, on vmentry, the processor applies specific checks to guest segment register state. These are listed in SDM Vol 3B, but they include checking that segment selector equals segment base address shifted right four bit positions, for example. Clearly the segment state in the dump you emailed is not valid for vm86 mode. Quite possibly PointSec doesn't expect to be in vm86 mode at all, and something may have gone wrong to set that bit in EFLAGS. But it's hard to say at arm's length.

-- Keir

Quoted 351 lines

Tom

2009/4/22 Keir Fraser <[email protected]>

Quoted 347 lines

Then it probably is a mis-emulation somewhere down the line. Unfortunately that could be hard to track down, even if we had PointSec software to hand, which we do not.

 -- Keir

Quoted 337 lines · Tom Rotenberg

Well, just tried this patch, and it doesn't seem to work. I get the following error:

(XEN) HVM1: Booting from 0000:7c00
(XEN) Failed vm entry (exit reason 0x80000021) caused by invalid guest state (0).
(XEN) ************* VMCS Area **************
(XEN) *** Guest State ***
(XEN) CR0: actual=0x0000000080010039, shadow=0x0000000080000019, gh_mask=ffffffffffffffff
(XEN) CR4: actual=0x0000000000002060, shadow=0x0000000000000000, gh_mask=ffffffffffffffff
(XEN) CR3: actual=0x000000000a22fa20, target_count=0
(XEN)      target0=0000000000000000, target1=0000000000000000 (XEN)      target2=0000000000000000, target3=0000000000000000 (XEN) RSP = 0x0000000000000080 (0x0000000000000080)  RIP = 0x000000000000002a
(0x000000000000002a)
(XEN) RFLAGS=0x0000000000023202 (0x0000000000023202)  DR7 = 0x0000000000000400
(XEN) Sysenter RSP=0000000000000000 CS:RIP=0000:0000000000000000 (XEN) CS: sel=0x0060, attr=0x0c09b, limit=0xffffffff, base=0x0000000000200000
(XEN) DS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) SS: sel=0x0070, attr=0x0c093, limit=0xfc000fff, base=0x000000000020ba62
(XEN) ES: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) FS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) GS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) GDTR:                           limit=0x00001dd8, base=0x0000000000200000
(XEN) LDTR: sel=0x0000, attr=0x1c000, limit=0xffffffff, base=0x0000000000000000
(XEN) IDTR:                           limit=0x00000188, base=0x0000000000201df0
(XEN) TR: sel=0x0058, attr=0x0008b, limit=0x0000ffff, base=0x0000000000201ff2
(XEN) Guest PAT = 0x0000000000000000
(XEN) TSC Offset = ffffffe2242f086e
(XEN) DebugCtl=0000000000000000 DebugExceptions=0000000000000000 (XEN) Interruptibility=0001 ActivityState=0000
(XEN) *** Host State ***
(XEN) RSP = 0xffff83007e4f7fa0  RIP = 0xffff828c8019aa20
(XEN) CS=e008 DS=0000 ES=0000 FS=0000 GS=0000 SS=0000 TR=e040 (XEN) FSBase=0000000000000000 GSBase=0000000000000000 TRBase=ffff828c802a8b00
(XEN) GDTBase=ffff83007e9a3000 IDTBase=ffff83007e62e010
(XEN) CR0=0000000080050033 CR3=000000007cfd8000 CR4=00000000000026f0 (XEN) Sysenter RSP=ffff83007e4f7fd0 CS:RIP=e008:ffff828c801c7290 (XEN) Host PAT = 0x0000000000000000
(XEN) *** Control State ***
(XEN) PinBased=0000003f CPUBased=b6a1e7fe SecondaryExec=00000041 (XEN) EntryControls=000011ff ExitControls=0003efff
(XEN) ExceptionBitmap=00044080
(XEN) VMEntry: intr_info=80000b0b errcode=00001eac ilen=00000000 (XEN) VMExit: intr_info=00000000 errcode=00008000 ilen=00000000 (XEN)         reason=80000021 qualification=00000000
(XEN) IDTVectoring: info=00000000 errcode=00000000
(XEN) TPR Threshold = 0x00
(XEN) EPT pointer = 0x0000000000000000
(XEN) Virtual processor ID = 0x0000
(XEN) **************************************
(XEN) domain_crash called from vmx.c:2218
(XEN) Domain 1 (vcpu#0) crashed on cpu#1:
(XEN) ----[ Xen-3.4.0-rc3-pre  x86_64  debug=n  Not tainted ]---- (XEN) CPU:    1
(XEN) RIP:    0060:[<000000000000002a>]
(XEN) RFLAGS: 0000000000023202   CONTEXT: hvm guest
(XEN) rax: 0000000000000007   rbx: 0000000000001490   rcx: 0000000000000000 (XEN) rdx: 0000000000001da8   rsi: 0000000000000000   rdi: 0000000000000000 (XEN) rbp: 0000000000008ebf   rsp: 0000000000000080   r8:  0000000000000000 (XEN) r9:  0000000000000000   r10: 0000000000000000   r11: 0000000000000000 (XEN) r12: 0000000000000000   r13: 0000000000000000   r14: 0000000000000000 (XEN) r15: 0000000000000000   cr0: 0000000080000019   cr4: 0000000000000000 (XEN) cr3: 0000000001443000   cr2: 0000000000000000
(XEN) ds: 0068   es: 0068   fs: 0068   gs: 0068   ss: 0070   cs: 0060

Any ideas?

Tom

2009/4/22 Keir Fraser <[email protected]>

Quoted 248 lines

That should do it.

 K.

Quoted 239 lines · Tom Rotenberg

Keir,
Just to make sure, i am using the following patch, in order to disable the vm86 acceleration:

diff -r cdc044f665dc xen/arch/x86/hvm/vmx/vmx.c

xen/arch/x86/hvm/vmx/vmx.c    Wed Apr 22 17:03:20 2009 +0300 renamed from xen/arch/x86/hvm/vmx/vmx.c    Wed Apr 22 11:26:37 2009 +0100 +0 -0
@@ -829,7 +829,7 @@


         if ( seg == x86_seg_tr )
         {
-            if ( v->domain->arch.hvm_domain.params[HVM_PARAM_VM86_TSS] ) +            if (0)
             {
                 sel = 0;
                 attr = vm86_tr_attr;

Is this OK?

Tom

2009/4/22 Keir Fraser <[email protected]>

Quoted 216 lines

Yes, the safest way to be sure is probably to replace the if() statement in
vmx_set_segment_register() that tests HVM_PARAM_VM86_TSS with if(0). That is
the only place in Xen that checks HVM_PARAM_VM86_TSS. Then you can re-build/install Xen and be sure that vm86 accel must be disabled.

 -- Keir

Quoted 203 lines · Tom Rotenberg

So, do u suggest, that i will set HVM_PARAM_VM86_TSS to 0, and re-check it?

2009/4/22 Tim Deegan <[email protected]>

Quoted 198 lines
Quoted 11 lines · Keir Fraser

It could be an issue with the vm86 acceleration, possibly. I'm pretty sure
the guest would have to IRET from protected mode to enter vm86 mode itself,
and we don't emulate that. Tim: what would we need to do to disable the
vm86
acceleration for testing purposes? You suggested not setting VM86_TSS param
from hvmloader, but I couldn't convince myself what effect that would actually have as the logic in Xen is non-trivial.

Yes; if HVM_PARAM_VM86_TSS is zero, vmx_set_segment_register() will always set the tss bit in the bitmap of segments that aren't safe to enter VM86 with.

Tim.

Quoted 174 lines

 -- Keir

Quoted 167 lines · Tom Rotenberg

Tim,

so what does it mean? could it be that we have a bug in the real mode emulation, which causes the segment state to be invalid (maybe it's because
of
a bug in the patch that Keir made for me, which emulated the LLDT, and
the
LTR
instructions)?

Keir suggested to trace back where the problem (segment state) occured,
and
from there to try and find the bug which caused it. Do u have any better
suggestion for solving this?

Tom

2009/4/22 Tim Deegan <[email protected]>

Quoted 144 lines
Quoted 17 lines · Tom Rotenberg

Keir,

I have tried your latest patch, and it looks like now it passes the emulation problem. However,  now the domain crashes with the following
error:

(XEN) HVM1: Booting from 0000:7c00
(XEN) Failed vm entry (exit reason 0x80000021) caused by invalid guest
state
(0).
(XEN) ************* VMCS Area **************
(XEN) *** Guest State ***
(XEN) CR0: actual=0x0000000080010039, shadow=0x0000000080000019, gh_mask=ffffffffffffffff
(XEN) CR4: actual=0x0000000000002060, shadow=0x0000000000000000,

Quoted 8 lines

gh_mask=ffffffffffffffff
(XEN) CR3: actual=0x000000000a213a20, target_count=0 (XEN)      target0=0000000000000000, target1=0000000000000000 (XEN)      target2=0000000000000000, target3=0000000000000000 (XEN) RSP = 0x0000000000000080 (0x0000000000000080)  RIP = 0x000000000000002a (0x000000000000002a)
(XEN) RFLAGS=0x0000000000023202 (0x0000000000023202)  DR7 = 0x0000000000000400

Looks like we're trying to VMENTER in virtual 8086 mode but without tidying up the segment state.  That could either be the guest entering
virtual 8086 mode itself or Xen entering vitrual 8086 mode to emulate
real mode, but Xen is always careful to make the segment state agree with Intel's rather strict requrements when it does that.

Tim.

Quoted 88 lines

(XEN) Sysenter RSP=0000000000000000 CS:RIP=0000:0000000000000000 (XEN) CS: sel=0x0060, attr=0x0c09b, limit=0xffffffff, base=0x0000000000200000
(XEN) DS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) SS: sel=0x0070, attr=0x0c093, limit=0xfc000fff, base=0x000000000020ba62
(XEN) ES: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) FS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) GS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) GDTR:                           limit=0x00001dd8, base=0x0000000000200000
(XEN) LDTR: sel=0x0000, attr=0x1c000, limit=0xffffffff, base=0x0000000000000000
(XEN) IDTR:                           limit=0x00000188, base=0x0000000000201df0
(XEN) TR: sel=0x0058, attr=0x0008b, limit=0x0000ffff, base=0x0000000000201ff2
(XEN) Guest PAT = 0x0000000000000000
(XEN) TSC Offset = ffffffe4920110b7
(XEN) DebugCtl=0000000000000000 DebugExceptions=0000000000000000 (XEN) Interruptibility=0001 ActivityState=0000
(XEN) *** Host State ***
(XEN) RSP = 0xffff83007e4f7fa0  RIP = 0xffff828c8019aa20 (XEN) CS=e008 DS=0000 ES=0000 FS=0000 GS=0000 SS=0000 TR=e040 (XEN) FSBase=0000000000000000 GSBase=0000000000000000 TRBase=ffff828c802a8b00
(XEN) GDTBase=ffff83007e9a3000 IDTBase=ffff83007e62e010 (XEN) CR0=0000000080050033 CR3=000000007cfdc000 CR4=00000000000026f0
(XEN) Sysenter RSP=ffff83007e4f7fd0 CS:RIP=e008:ffff828c801c7290 (XEN) Host PAT = 0x0000000000000000
(XEN) *** Control State ***
(XEN) PinBased=0000003f CPUBased=b6a1e7fe SecondaryExec=00000041 (XEN) EntryControls=000011ff ExitControls=0003efff (XEN) ExceptionBitmap=00044080
(XEN) VMEntry: intr_info=80000b0b errcode=00001eac ilen=00000000 (XEN) VMExit: intr_info=00000000 errcode=00008000 ilen=00000000 (XEN)         reason=80000021 qualification=00000000 (XEN) IDTVectoring: info=00000000 errcode=00000000 (XEN) TPR Threshold = 0x00
(XEN) EPT pointer = 0x0000000000000000
(XEN) Virtual processor ID = 0x0000
(XEN) **************************************
(XEN) domain_crash called from vmx.c:2218
(XEN) Domain 1 (vcpu#0) crashed on cpu#1:
(XEN) ----[ Xen-3.4.0-rc3-pre  x86_64  debug=n  Not tainted ]---- (XEN) CPU:    1
(XEN) RIP:    0060:[<000000000000002a>]
(XEN) RFLAGS: 0000000000023202   CONTEXT: hvm guest (XEN) rax: 0000000000000007   rbx: 0000000000001490   rcx:
0000000000000000
(XEN) rdx: 0000000000001da8   rsi: 0000000000000000   rdi:
0000000000000000
(XEN) rbp: 0000000000008ebf   rsp: 0000000000000080   r8:
 0000000000000000
(XEN) r9:  0000000000000000   r10: 0000000000000000   r11:
0000000000000000
(XEN) r12: 0000000000000000   r13: 0000000000000000   r14:
0000000000000000
(XEN) r15: 0000000000000000   cr0: 0000000080000019   cr4:
0000000000000000
(XEN) cr3: 0000000001443000   cr2: 0000000000000000 (XEN) ds: 0068   es: 0068   fs: 0068   gs: 0068   ss: 0070   cs:
0060

Could it be, that the real mode emulation code has a bug? What does this
error means?

Tom

2009/4/22 Keir Fraser <[email protected]<mailto:[email protected]>>

Quoted 7 lines · On 22/04/2009 12:18, "Tom Rotenberg" <[email protected]<mailto:tom.rotenb…

Keir,

I have applied your patch, and it seemed to work. However, the
domain
still
crashes, and now it looks like it's because of the 'LTR'
instruction.

Quoted 6 lines

Try the attached patch. It replaces the one I sent last time, and emulates
both LLDT and LTR.

 -- Keir

Content-Description: ATT00001.txt

Quoted 4 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

--
Tim Deegan <[email protected]>
Principal Software Engineer, Citrix Systems (R&D) Ltd. [Company #02300071, SL9 0DZ, UK.]

--
Tim Deegan <[email protected]>
Principal Software Engineer, Citrix Systems (R&D) Ltd. [Company #02300071, SL9 0DZ, UK.]

#20 lore raw

Ok, thanks for all the information. I will digg into it, and let u know, if i have any further questions.
Thanks.

2009/4/22 Keir Fraser <[email protected]>

Quoted 382 lines · Tom Rotenberg
Quoted 2 lines

So, do u have any suggestion for me, on how to advance with this issue?

should

Quoted 1 line

i debug the real mode emulation myself in order to track it down? will u

be

Quoted 1 line

able top assist me in any way with this issue?

If specific questions arise then certainly yes.

Quoted 1 line

BTW - what is exactly the problem which causes this exception from the

CPU?

Quoted 1 line

Tim mentioned something about segment state - can u please elaborate on

this

Quoted 1 line

issue?

Bit 17 in EFLAGS is set, meaning the guest is in vm86 mode. In this mode, on
vmentry, the processor applies specific checks to guest segment register state. These are listed in SDM Vol 3B, but they include checking that segment selector equals segment base address shifted right four bit positions, for example. Clearly the segment state in the dump you emailed is
not valid for vm86 mode. Quite possibly PointSec doesn't expect to be in vm86 mode at all, and something may have gone wrong to set that bit in EFLAGS. But it's hard to say at arm's length.

-- Keir

Quoted 4 lines

Tom

2009/4/22 Keir Fraser <[email protected]>

Quoted 1 line

Then it probably is a mis-emulation somewhere down the line.

Unfortunately

Quoted 1 line
Quoted 1 line

that could be hard to track down, even if we had PointSec software to

hand,

Quoted 11 lines
Quoted 11 lines

which we do not.

-- Keir

Quoted 5 lines · Tom Rotenberg

Well, just tried this patch, and it doesn't seem to work. I get the following error:

(XEN) HVM1: Booting from 0000:7c00
(XEN) Failed vm entry (exit reason 0x80000021) caused by invalid guest

state

Quoted 60 lines
Quoted 60 lines
Quoted 60 lines

(0).
(XEN) ************* VMCS Area **************
(XEN) *** Guest State ***
(XEN) CR0: actual=0x0000000080010039, shadow=0x0000000080000019, gh_mask=ffffffffffffffff
(XEN) CR4: actual=0x0000000000002060, shadow=0x0000000000000000, gh_mask=ffffffffffffffff
(XEN) CR3: actual=0x000000000a22fa20, target_count=0
(XEN) target0=0000000000000000, target1=0000000000000000
(XEN) target2=0000000000000000, target3=0000000000000000
(XEN) RSP = 0x0000000000000080 (0x0000000000000080) RIP = 0x000000000000002a
(0x000000000000002a)
(XEN) RFLAGS=0x0000000000023202 (0x0000000000023202) DR7 = 0x0000000000000400
(XEN) Sysenter RSP=0000000000000000 CS:RIP=0000:0000000000000000 (XEN) CS: sel=0x0060, attr=0x0c09b, limit=0xffffffff, base=0x0000000000200000
(XEN) DS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) SS: sel=0x0070, attr=0x0c093, limit=0xfc000fff, base=0x000000000020ba62
(XEN) ES: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) FS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) GS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) GDTR: limit=0x00001dd8,
base=0x0000000000200000
(XEN) LDTR: sel=0x0000, attr=0x1c000, limit=0xffffffff, base=0x0000000000000000
(XEN) IDTR: limit=0x00000188,
base=0x0000000000201df0
(XEN) TR: sel=0x0058, attr=0x0008b, limit=0x0000ffff, base=0x0000000000201ff2
(XEN) Guest PAT = 0x0000000000000000
(XEN) TSC Offset = ffffffe2242f086e
(XEN) DebugCtl=0000000000000000 DebugExceptions=0000000000000000 (XEN) Interruptibility=0001 ActivityState=0000
(XEN) *** Host State ***
(XEN) RSP = 0xffff83007e4f7fa0 RIP = 0xffff828c8019aa20 (XEN) CS=e008 DS=0000 ES=0000 FS=0000 GS=0000 SS=0000 TR=e040 (XEN) FSBase=0000000000000000 GSBase=0000000000000000 TRBase=ffff828c802a8b00
(XEN) GDTBase=ffff83007e9a3000 IDTBase=ffff83007e62e010 (XEN) CR0=0000000080050033 CR3=000000007cfd8000 CR4=00000000000026f0 (XEN) Sysenter RSP=ffff83007e4f7fd0 CS:RIP=e008:ffff828c801c7290 (XEN) Host PAT = 0x0000000000000000
(XEN) *** Control State ***
(XEN) PinBased=0000003f CPUBased=b6a1e7fe SecondaryExec=00000041 (XEN) EntryControls=000011ff ExitControls=0003efff
(XEN) ExceptionBitmap=00044080
(XEN) VMEntry: intr_info=80000b0b errcode=00001eac ilen=00000000 (XEN) VMExit: intr_info=00000000 errcode=00008000 ilen=00000000
(XEN) reason=80000021 qualification=00000000
(XEN) IDTVectoring: info=00000000 errcode=00000000
(XEN) TPR Threshold = 0x00
(XEN) EPT pointer = 0x0000000000000000
(XEN) Virtual processor ID = 0x0000

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

(XEN) **************************************
(XEN) domain_crash called from vmx.c:2218
(XEN) Domain 1 (vcpu#0) crashed on cpu#1:
(XEN) ----[ Xen-3.4.0-rc3-pre x86_64 debug=n Not tainted ]----
(XEN) CPU: 1
(XEN) RIP: 0060:[<000000000000002a>]
(XEN) RFLAGS: 0000000000023202 CONTEXT: hvm guest
(XEN) rax: 0000000000000007 rbx: 0000000000001490 rcx:

0000000000000000

Quoted 1 line
Quoted 1 line
Quoted 1 line

(XEN) rdx: 0000000000001da8 rsi: 0000000000000000 rdi:

0000000000000000

Quoted 1 line
Quoted 1 line
Quoted 1 line

(XEN) rbp: 0000000000008ebf rsp: 0000000000000080 r8:

0000000000000000

Quoted 1 line
Quoted 1 line
Quoted 1 line

(XEN) r9: 0000000000000000 r10: 0000000000000000 r11:

0000000000000000

Quoted 1 line
Quoted 1 line
Quoted 1 line

(XEN) r12: 0000000000000000 r13: 0000000000000000 r14:

0000000000000000

Quoted 1 line
Quoted 1 line
Quoted 1 line

(XEN) r15: 0000000000000000 cr0: 0000000080000019 cr4:

0000000000000000

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines

(XEN) cr3: 0000000001443000 cr2: 0000000000000000
(XEN) ds: 0068 es: 0068 fs: 0068 gs: 0068 ss: 0070 cs: 0060

Any ideas?

Tom

2009/4/22 Keir Fraser <[email protected]>

Quoted 2 lines

That should do it.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

K.

Quoted 2 lines · Tom Rotenberg

Keir,
Just to make sure, i am using the following patch, in order to

disable the

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

xen/arch/x86/hvm/vmx/vmx.c Wed Apr 22 17:03:20 2009 +0300 line 832

Quoted 10 lines

vm86 acceleration:

diff -r cdc044f665dc xen/arch/x86/hvm/vmx/vmx.c

xen/arch/x86/hvm/vmx/vmx.c Wed Apr 22 17:03:20 2009 +0300 renamed from xen/arch/x86/hvm/vmx/vmx.c Wed Apr 22 11:26:37 2009 +0100 +0 -1
@@ -829,7 +829,7 @@
 
         if ( seg == x86_seg_tr )
         {
-            if (

v->domain->arch.hvm_domain.params[HVM_PARAM_VM86_TSS] )

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
xen/arch/x86/hvm/vmx/vmx.c Wed Apr 22 17:03:20 2009 +0300 renamed from xen/arch/x86/hvm/vmx/vmx.c Wed Apr 22 11:26:37 2009 +0100 +1 -0
+            if (0)
             {
                 sel = 0;
                 attr = vm86_tr_attr;

Is this OK?

Tom

2009/4/22 Keir Fraser <[email protected]>

Quoted 1 line

Yes, the safest way to be sure is probably to replace the if()

statement

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

in
vmx_set_segment_register() that tests HVM_PARAM_VM86_TSS with if(0).

That

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

is
the only place in Xen that checks HVM_PARAM_VM86_TSS. Then you can re-build/install Xen and be sure that vm86 accel must be disabled.

-- Keir

On 22/04/2009 14:52, "Tom Rotenberg" <[email protected]>

Quoted 2 lines · wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

So, do u suggest, that i will set HVM_PARAM_VM86_TSS to 0, and

re-check

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

it?

2009/4/22 Tim Deegan <[email protected]>

Quoted 2 lines
Quoted 1 line · Keir Fraser

It could be an issue with the vm86 acceleration, possibly. I'm

pretty

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

sure
the guest would have to IRET from protected mode to enter vm86

mode

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

itself,
and we don't emulate that. Tim: what would we need to do to

disable

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

the
vm86
acceleration for testing purposes? You suggested not setting

VM86_TSS

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

param
from hvmloader, but I couldn't convince myself what effect that

would

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

actually have as the logic in Xen is non-trivial.

Yes; if HVM_PARAM_VM86_TSS is zero, vmx_set_segment_register()

will

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

always set the tss bit in the bitmap of segments that aren't safe

to

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

enter VM86 with.

Tim.

Quoted 4 lines

-- Keir

On 22/04/2009 14:23, "Tom Rotenberg" <[email protected]>

Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Tim,

so what does it mean? could it be that we have a bug in the real

mode

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

emulation, which causes the segment state to be invalid (maybe

it's

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

because
of
a bug in the patch that Keir made for me, which emulated the

LLDT,

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

and
the
LTR
instructions)?

Keir suggested to trace back where the problem (segment state) occured,
and
from there to try and find the bug which caused it. Do u have

any

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

better
suggestion for solving this?

Tom

2009/4/22 Tim Deegan <[email protected]>

Quoted 4 lines
Quoted 3 lines · Tom Rotenberg

Keir,

I have tried your latest patch, and it looks like now it

passes the

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

emulation problem. However, now the domain crashes with the
following
error:

(XEN) HVM1: Booting from 0000:7c00
(XEN) Failed vm entry (exit reason 0x80000021) caused by

invalid

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

guest
state
(0).
(XEN) ************* VMCS Area **************
(XEN) *** Guest State ***
(XEN) CR0: actual=0x0000000080010039,

shadow=0x0000000080000019,

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

gh_mask=ffffffffffffffff
(XEN) CR4: actual=0x0000000000002060,

shadow=0x0000000000000000,

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 8 lines

gh_mask=ffffffffffffffff
(XEN) CR3: actual=0x000000000a213a20, target_count=0
(XEN) target0=0000000000000000, target1=0000000000000000
(XEN) target2=0000000000000000, target3=0000000000000000
(XEN) RSP = 0x0000000000000080 (0x0000000000000080) RIP =
0x000000000000002a (0x000000000000002a)
(XEN) RFLAGS=0x0000000000023202 (0x0000000000023202) DR7 =
0x0000000000000400

Looks like we're trying to VMENTER in virtual 8086 mode but

without

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

tidying up the segment state. That could either be the guest entering
virtual 8086 mode itself or Xen entering vitrual 8086 mode to emulate
real mode, but Xen is always careful to make the segment state

agree

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

with Intel's rather strict requrements when it does that.

Tim.

Quoted 1 line

(XEN) Sysenter RSP=0000000000000000

CS:RIP=0000:0000000000000000

Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines

(XEN) CS: sel=0x0060, attr=0x0c09b, limit=0xffffffff,
base=0x0000000000200000
(XEN) DS: sel=0x0068, attr=0x0c093, limit=0xffffffff,
base=0x0000000000200000
(XEN) SS: sel=0x0070, attr=0x0c093, limit=0xfc000fff,
base=0x000000000020ba62
(XEN) ES: sel=0x0068, attr=0x0c093, limit=0xffffffff,
base=0x0000000000200000
(XEN) FS: sel=0x0068, attr=0x0c093, limit=0xffffffff,
base=0x0000000000200000
(XEN) GS: sel=0x0068, attr=0x0c093, limit=0xffffffff,
base=0x0000000000200000
(XEN) GDTR: limit=0x00001dd8,
base=0x0000000000200000
(XEN) LDTR: sel=0x0000, attr=0x1c000, limit=0xffffffff,

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

base=0x0000000000000000
(XEN) IDTR: limit=0x00000188,
base=0x0000000000201df0
(XEN) TR: sel=0x0058, attr=0x0008b, limit=0x0000ffff,
base=0x0000000000201ff2
(XEN) Guest PAT = 0x0000000000000000
(XEN) TSC Offset = ffffffe4920110b7
(XEN) DebugCtl=0000000000000000

DebugExceptions=0000000000000000

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

(XEN) Interruptibility=0001 ActivityState=0000
(XEN) *** Host State ***
(XEN) RSP = 0xffff83007e4f7fa0 RIP = 0xffff828c8019aa20
(XEN) CS=e008 DS=0000 ES=0000 FS=0000 GS=0000 SS=0000 TR=e040
(XEN) FSBase=0000000000000000 GSBase=0000000000000000
TRBase=ffff828c802a8b00
(XEN) GDTBase=ffff83007e9a3000 IDTBase=ffff83007e62e010
(XEN) CR0=0000000080050033 CR3=000000007cfdc000
CR4=00000000000026f0
(XEN) Sysenter RSP=ffff83007e4f7fd0

CS:RIP=e008:ffff828c801c7290

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

(XEN) Host PAT = 0x0000000000000000
(XEN) *** Control State ***
(XEN) PinBased=0000003f CPUBased=b6a1e7fe

SecondaryExec=00000041

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

(XEN) EntryControls=000011ff ExitControls=0003efff
(XEN) ExceptionBitmap=00044080
(XEN) VMEntry: intr_info=80000b0b errcode=00001eac

ilen=00000000

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

(XEN) VMExit: intr_info=00000000 errcode=00008000

ilen=00000000

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

(XEN) reason=80000021 qualification=00000000
(XEN) IDTVectoring: info=00000000 errcode=00000000
(XEN) TPR Threshold = 0x00
(XEN) EPT pointer = 0x0000000000000000
(XEN) Virtual processor ID = 0x0000
(XEN) **************************************
(XEN) domain_crash called from vmx.c:2218
(XEN) Domain 1 (vcpu#0) crashed on cpu#1:
(XEN) ----[ Xen-3.4.0-rc3-pre x86_64 debug=n Not tainted

]----

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

(XEN) CPU: 1
(XEN) RIP: 0060:[<000000000000002a>]
(XEN) RFLAGS: 0000000000023202 CONTEXT: hvm guest
(XEN) rax: 0000000000000007 rbx: 0000000000001490 rcx:
0000000000000000
(XEN) rdx: 0000000000001da8 rsi: 0000000000000000 rdi:
0000000000000000
(XEN) rbp: 0000000000008ebf rsp: 0000000000000080 r8:
0000000000000000

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

(XEN) r9: 0000000000000000 r10: 0000000000000000 r11:
0000000000000000
(XEN) r12: 0000000000000000 r13: 0000000000000000 r14:
0000000000000000
(XEN) r15: 0000000000000000 cr0: 0000000080000019 cr4:
0000000000000000
(XEN) cr3: 0000000001443000 cr2: 0000000000000000
(XEN) ds: 0068 es: 0068 fs: 0068 gs: 0068 ss: 0070

cs:

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

0060

Could it be, that the real mode emulation code has a bug? What

does

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

this
error means?

Tom

2009/4/22 Keir Fraser
<[email protected]<mailto:[email protected]>>
On 22/04/2009 12:18, "Tom Rotenberg"
<[email protected]<mailto:[email protected]>>

Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Keir,

I have applied your patch, and it seemed to work. However,

Quoted 46 lines

the

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

domain
still
crashes, and now it looks like it's because of the 'LTR'
instruction.

Try the attached patch. It replaces the one I sent last time,

and

Quoted 35 lines
Quoted 34 lines
Quoted 32 lines
Quoted 31 lines
Quoted 29 lines
Quoted 28 lines
Quoted 26 lines
Quoted 25 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 5 lines

emulates
both LLDT and LTR.

-- Keir

Content-Description: ATT00001.txt

Quoted 4 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

Quoted 7 lines
Quoted 5 lines
Quoted 4 lines

--
Tim Deegan <[email protected]>
Principal Software Engineer, Citrix Systems (R&D) Ltd. [Company #02300071, SL9 0DZ, UK.]

--
Tim Deegan <[email protected]>
Principal Software Engineer, Citrix Systems (R&D) Ltd. [Company #02300071, SL9 0DZ, UK.]

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#21 lore raw
In reply to Keir Fraser

Keir,

Is there any tool, which allows debugging step by step of the boot sequence (starting from the point which the hvmloader transfers control to the MBR)? If there is such tool, i will be able to debug it step by step, and compare it to a real machine, and thus, hopefully find the bug.

Tom

2009/4/22 Keir Fraser <[email protected]>

Quoted 382 lines · Tom Rotenberg
Quoted 2 lines

So, do u have any suggestion for me, on how to advance with this issue?

should

Quoted 1 line

i debug the real mode emulation myself in order to track it down? will u

be

Quoted 1 line

able top assist me in any way with this issue?

If specific questions arise then certainly yes.

Quoted 1 line

BTW - what is exactly the problem which causes this exception from the

CPU?

Quoted 1 line

Tim mentioned something about segment state - can u please elaborate on

this

Quoted 1 line

issue?

Bit 17 in EFLAGS is set, meaning the guest is in vm86 mode. In this mode, on
vmentry, the processor applies specific checks to guest segment register state. These are listed in SDM Vol 3B, but they include checking that segment selector equals segment base address shifted right four bit positions, for example. Clearly the segment state in the dump you emailed is
not valid for vm86 mode. Quite possibly PointSec doesn't expect to be in vm86 mode at all, and something may have gone wrong to set that bit in EFLAGS. But it's hard to say at arm's length.

-- Keir

Quoted 4 lines

Tom

2009/4/22 Keir Fraser <[email protected]>

Quoted 1 line

Then it probably is a mis-emulation somewhere down the line.

Unfortunately

Quoted 1 line
Quoted 1 line

that could be hard to track down, even if we had PointSec software to

hand,

Quoted 11 lines
Quoted 11 lines

which we do not.

-- Keir

Quoted 5 lines · Tom Rotenberg

Well, just tried this patch, and it doesn't seem to work. I get the following error:

(XEN) HVM1: Booting from 0000:7c00
(XEN) Failed vm entry (exit reason 0x80000021) caused by invalid guest

state

Quoted 60 lines
Quoted 60 lines
Quoted 60 lines

(0).
(XEN) ************* VMCS Area **************
(XEN) *** Guest State ***
(XEN) CR0: actual=0x0000000080010039, shadow=0x0000000080000019, gh_mask=ffffffffffffffff
(XEN) CR4: actual=0x0000000000002060, shadow=0x0000000000000000, gh_mask=ffffffffffffffff
(XEN) CR3: actual=0x000000000a22fa20, target_count=0
(XEN) target0=0000000000000000, target1=0000000000000000
(XEN) target2=0000000000000000, target3=0000000000000000
(XEN) RSP = 0x0000000000000080 (0x0000000000000080) RIP = 0x000000000000002a
(0x000000000000002a)
(XEN) RFLAGS=0x0000000000023202 (0x0000000000023202) DR7 = 0x0000000000000400
(XEN) Sysenter RSP=0000000000000000 CS:RIP=0000:0000000000000000 (XEN) CS: sel=0x0060, attr=0x0c09b, limit=0xffffffff, base=0x0000000000200000
(XEN) DS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) SS: sel=0x0070, attr=0x0c093, limit=0xfc000fff, base=0x000000000020ba62
(XEN) ES: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) FS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) GS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) GDTR: limit=0x00001dd8,
base=0x0000000000200000
(XEN) LDTR: sel=0x0000, attr=0x1c000, limit=0xffffffff, base=0x0000000000000000
(XEN) IDTR: limit=0x00000188,
base=0x0000000000201df0
(XEN) TR: sel=0x0058, attr=0x0008b, limit=0x0000ffff, base=0x0000000000201ff2
(XEN) Guest PAT = 0x0000000000000000
(XEN) TSC Offset = ffffffe2242f086e
(XEN) DebugCtl=0000000000000000 DebugExceptions=0000000000000000 (XEN) Interruptibility=0001 ActivityState=0000
(XEN) *** Host State ***
(XEN) RSP = 0xffff83007e4f7fa0 RIP = 0xffff828c8019aa20 (XEN) CS=e008 DS=0000 ES=0000 FS=0000 GS=0000 SS=0000 TR=e040 (XEN) FSBase=0000000000000000 GSBase=0000000000000000 TRBase=ffff828c802a8b00
(XEN) GDTBase=ffff83007e9a3000 IDTBase=ffff83007e62e010 (XEN) CR0=0000000080050033 CR3=000000007cfd8000 CR4=00000000000026f0 (XEN) Sysenter RSP=ffff83007e4f7fd0 CS:RIP=e008:ffff828c801c7290 (XEN) Host PAT = 0x0000000000000000
(XEN) *** Control State ***
(XEN) PinBased=0000003f CPUBased=b6a1e7fe SecondaryExec=00000041 (XEN) EntryControls=000011ff ExitControls=0003efff
(XEN) ExceptionBitmap=00044080
(XEN) VMEntry: intr_info=80000b0b errcode=00001eac ilen=00000000 (XEN) VMExit: intr_info=00000000 errcode=00008000 ilen=00000000
(XEN) reason=80000021 qualification=00000000
(XEN) IDTVectoring: info=00000000 errcode=00000000
(XEN) TPR Threshold = 0x00
(XEN) EPT pointer = 0x0000000000000000
(XEN) Virtual processor ID = 0x0000

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

(XEN) **************************************
(XEN) domain_crash called from vmx.c:2218
(XEN) Domain 1 (vcpu#0) crashed on cpu#1:
(XEN) ----[ Xen-3.4.0-rc3-pre x86_64 debug=n Not tainted ]----
(XEN) CPU: 1
(XEN) RIP: 0060:[<000000000000002a>]
(XEN) RFLAGS: 0000000000023202 CONTEXT: hvm guest
(XEN) rax: 0000000000000007 rbx: 0000000000001490 rcx:

0000000000000000

Quoted 1 line
Quoted 1 line
Quoted 1 line

(XEN) rdx: 0000000000001da8 rsi: 0000000000000000 rdi:

0000000000000000

Quoted 1 line
Quoted 1 line
Quoted 1 line

(XEN) rbp: 0000000000008ebf rsp: 0000000000000080 r8:

0000000000000000

Quoted 1 line
Quoted 1 line
Quoted 1 line

(XEN) r9: 0000000000000000 r10: 0000000000000000 r11:

0000000000000000

Quoted 1 line
Quoted 1 line
Quoted 1 line

(XEN) r12: 0000000000000000 r13: 0000000000000000 r14:

0000000000000000

Quoted 1 line
Quoted 1 line
Quoted 1 line

(XEN) r15: 0000000000000000 cr0: 0000000080000019 cr4:

0000000000000000

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines

(XEN) cr3: 0000000001443000 cr2: 0000000000000000
(XEN) ds: 0068 es: 0068 fs: 0068 gs: 0068 ss: 0070 cs: 0060

Any ideas?

Tom

2009/4/22 Keir Fraser <[email protected]>

Quoted 2 lines

That should do it.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

K.

Quoted 2 lines · Tom Rotenberg

Keir,
Just to make sure, i am using the following patch, in order to

disable the

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

xen/arch/x86/hvm/vmx/vmx.c Wed Apr 22 17:03:20 2009 +0300 line 832

Quoted 10 lines

vm86 acceleration:

diff -r cdc044f665dc xen/arch/x86/hvm/vmx/vmx.c

xen/arch/x86/hvm/vmx/vmx.c Wed Apr 22 17:03:20 2009 +0300 renamed from xen/arch/x86/hvm/vmx/vmx.c Wed Apr 22 11:26:37 2009 +0100 +0 -1
@@ -829,7 +829,7 @@
 
         if ( seg == x86_seg_tr )
         {
-            if (

v->domain->arch.hvm_domain.params[HVM_PARAM_VM86_TSS] )

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
xen/arch/x86/hvm/vmx/vmx.c Wed Apr 22 17:03:20 2009 +0300 renamed from xen/arch/x86/hvm/vmx/vmx.c Wed Apr 22 11:26:37 2009 +0100 +1 -0
+            if (0)
             {
                 sel = 0;
                 attr = vm86_tr_attr;

Is this OK?

Tom

2009/4/22 Keir Fraser <[email protected]>

Quoted 1 line

Yes, the safest way to be sure is probably to replace the if()

statement

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

in
vmx_set_segment_register() that tests HVM_PARAM_VM86_TSS with if(0).

That

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

is
the only place in Xen that checks HVM_PARAM_VM86_TSS. Then you can re-build/install Xen and be sure that vm86 accel must be disabled.

-- Keir

On 22/04/2009 14:52, "Tom Rotenberg" <[email protected]>

Quoted 2 lines · wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

So, do u suggest, that i will set HVM_PARAM_VM86_TSS to 0, and

re-check

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

it?

2009/4/22 Tim Deegan <[email protected]>

Quoted 2 lines
Quoted 1 line · Keir Fraser

It could be an issue with the vm86 acceleration, possibly. I'm

pretty

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

sure
the guest would have to IRET from protected mode to enter vm86

mode

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

itself,
and we don't emulate that. Tim: what would we need to do to

disable

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

the
vm86
acceleration for testing purposes? You suggested not setting

VM86_TSS

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

param
from hvmloader, but I couldn't convince myself what effect that

would

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

actually have as the logic in Xen is non-trivial.

Yes; if HVM_PARAM_VM86_TSS is zero, vmx_set_segment_register()

will

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

always set the tss bit in the bitmap of segments that aren't safe

to

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

enter VM86 with.

Tim.

Quoted 4 lines

-- Keir

On 22/04/2009 14:23, "Tom Rotenberg" <[email protected]>

Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Tim,

so what does it mean? could it be that we have a bug in the real

mode

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

emulation, which causes the segment state to be invalid (maybe

it's

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

because
of
a bug in the patch that Keir made for me, which emulated the

LLDT,

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

and
the
LTR
instructions)?

Keir suggested to trace back where the problem (segment state) occured,
and
from there to try and find the bug which caused it. Do u have

any

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

better
suggestion for solving this?

Tom

2009/4/22 Tim Deegan <[email protected]>

Quoted 4 lines
Quoted 3 lines · Tom Rotenberg

Keir,

I have tried your latest patch, and it looks like now it

passes the

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

emulation problem. However, now the domain crashes with the
following
error:

(XEN) HVM1: Booting from 0000:7c00
(XEN) Failed vm entry (exit reason 0x80000021) caused by

invalid

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

guest
state
(0).
(XEN) ************* VMCS Area **************
(XEN) *** Guest State ***
(XEN) CR0: actual=0x0000000080010039,

shadow=0x0000000080000019,

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

gh_mask=ffffffffffffffff
(XEN) CR4: actual=0x0000000000002060,

shadow=0x0000000000000000,

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 8 lines

gh_mask=ffffffffffffffff
(XEN) CR3: actual=0x000000000a213a20, target_count=0
(XEN) target0=0000000000000000, target1=0000000000000000
(XEN) target2=0000000000000000, target3=0000000000000000
(XEN) RSP = 0x0000000000000080 (0x0000000000000080) RIP =
0x000000000000002a (0x000000000000002a)
(XEN) RFLAGS=0x0000000000023202 (0x0000000000023202) DR7 =
0x0000000000000400

Looks like we're trying to VMENTER in virtual 8086 mode but

without

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

tidying up the segment state. That could either be the guest entering
virtual 8086 mode itself or Xen entering vitrual 8086 mode to emulate
real mode, but Xen is always careful to make the segment state

agree

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

with Intel's rather strict requrements when it does that.

Tim.

Quoted 1 line

(XEN) Sysenter RSP=0000000000000000

CS:RIP=0000:0000000000000000

Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines

(XEN) CS: sel=0x0060, attr=0x0c09b, limit=0xffffffff,
base=0x0000000000200000
(XEN) DS: sel=0x0068, attr=0x0c093, limit=0xffffffff,
base=0x0000000000200000
(XEN) SS: sel=0x0070, attr=0x0c093, limit=0xfc000fff,
base=0x000000000020ba62
(XEN) ES: sel=0x0068, attr=0x0c093, limit=0xffffffff,
base=0x0000000000200000
(XEN) FS: sel=0x0068, attr=0x0c093, limit=0xffffffff,
base=0x0000000000200000
(XEN) GS: sel=0x0068, attr=0x0c093, limit=0xffffffff,
base=0x0000000000200000
(XEN) GDTR: limit=0x00001dd8,
base=0x0000000000200000
(XEN) LDTR: sel=0x0000, attr=0x1c000, limit=0xffffffff,

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

base=0x0000000000000000
(XEN) IDTR: limit=0x00000188,
base=0x0000000000201df0
(XEN) TR: sel=0x0058, attr=0x0008b, limit=0x0000ffff,
base=0x0000000000201ff2
(XEN) Guest PAT = 0x0000000000000000
(XEN) TSC Offset = ffffffe4920110b7
(XEN) DebugCtl=0000000000000000

DebugExceptions=0000000000000000

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

(XEN) Interruptibility=0001 ActivityState=0000
(XEN) *** Host State ***
(XEN) RSP = 0xffff83007e4f7fa0 RIP = 0xffff828c8019aa20
(XEN) CS=e008 DS=0000 ES=0000 FS=0000 GS=0000 SS=0000 TR=e040
(XEN) FSBase=0000000000000000 GSBase=0000000000000000
TRBase=ffff828c802a8b00
(XEN) GDTBase=ffff83007e9a3000 IDTBase=ffff83007e62e010
(XEN) CR0=0000000080050033 CR3=000000007cfdc000
CR4=00000000000026f0
(XEN) Sysenter RSP=ffff83007e4f7fd0

CS:RIP=e008:ffff828c801c7290

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

(XEN) Host PAT = 0x0000000000000000
(XEN) *** Control State ***
(XEN) PinBased=0000003f CPUBased=b6a1e7fe

SecondaryExec=00000041

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

(XEN) EntryControls=000011ff ExitControls=0003efff
(XEN) ExceptionBitmap=00044080
(XEN) VMEntry: intr_info=80000b0b errcode=00001eac

ilen=00000000

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

(XEN) VMExit: intr_info=00000000 errcode=00008000

ilen=00000000

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

(XEN) reason=80000021 qualification=00000000
(XEN) IDTVectoring: info=00000000 errcode=00000000
(XEN) TPR Threshold = 0x00
(XEN) EPT pointer = 0x0000000000000000
(XEN) Virtual processor ID = 0x0000
(XEN) **************************************
(XEN) domain_crash called from vmx.c:2218
(XEN) Domain 1 (vcpu#0) crashed on cpu#1:
(XEN) ----[ Xen-3.4.0-rc3-pre x86_64 debug=n Not tainted

]----

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

(XEN) CPU: 1
(XEN) RIP: 0060:[<000000000000002a>]
(XEN) RFLAGS: 0000000000023202 CONTEXT: hvm guest
(XEN) rax: 0000000000000007 rbx: 0000000000001490 rcx:
0000000000000000
(XEN) rdx: 0000000000001da8 rsi: 0000000000000000 rdi:
0000000000000000
(XEN) rbp: 0000000000008ebf rsp: 0000000000000080 r8:
0000000000000000

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

(XEN) r9: 0000000000000000 r10: 0000000000000000 r11:
0000000000000000
(XEN) r12: 0000000000000000 r13: 0000000000000000 r14:
0000000000000000
(XEN) r15: 0000000000000000 cr0: 0000000080000019 cr4:
0000000000000000
(XEN) cr3: 0000000001443000 cr2: 0000000000000000
(XEN) ds: 0068 es: 0068 fs: 0068 gs: 0068 ss: 0070

cs:

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

0060

Could it be, that the real mode emulation code has a bug? What

does

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

this
error means?

Tom

2009/4/22 Keir Fraser
<[email protected]<mailto:[email protected]>>
On 22/04/2009 12:18, "Tom Rotenberg"
<[email protected]<mailto:[email protected]>>

Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Keir,

I have applied your patch, and it seemed to work. However,

Quoted 46 lines

the

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

domain
still
crashes, and now it looks like it's because of the 'LTR'
instruction.

Try the attached patch. It replaces the one I sent last time,

and

Quoted 35 lines
Quoted 34 lines
Quoted 32 lines
Quoted 31 lines
Quoted 29 lines
Quoted 28 lines
Quoted 26 lines
Quoted 25 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 5 lines

emulates
both LLDT and LTR.

-- Keir

Content-Description: ATT00001.txt

Quoted 4 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

Quoted 7 lines
Quoted 5 lines
Quoted 4 lines

--
Tim Deegan <[email protected]>
Principal Software Engineer, Citrix Systems (R&D) Ltd. [Company #02300071, SL9 0DZ, UK.]

--
Tim Deegan <[email protected]>
Principal Software Engineer, Citrix Systems (R&D) Ltd. [Company #02300071, SL9 0DZ, UK.]

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#22 lore raw

I don't think we have anything obvious for dealing with single stepping of real mode and 16-bit protected mode. Not to mention that sometimes these bugs occur after execution of many thousands of instructions, which makes a single step approach impractical.

-- Keir

Quoted 409 lines · Tom Rotenberg

Keir,

Is there any tool, which allows debugging step by step of the boot sequence (starting from the point which the hvmloader transfers control to the MBR)? If there is such tool, i will be able to debug it step by step, and compare it to a real machine, and thus, hopefully find the bug.

Tom

2009/4/22 Keir Fraser <[email protected]>

Quoted 398 lines · Tom Rotenberg
Quoted 5 lines

So, do u have any suggestion for me, on how to advance with this issue? should
i debug the real mode emulation myself in order to track it down? will u be able top assist me in any way with this issue?

If specific questions arise then certainly yes.

Quoted 3 lines

BTW - what is exactly the problem which causes this exception from the CPU? Tim mentioned something about segment state - can u please elaborate on this issue?

Bit 17 in EFLAGS is set, meaning the guest is in vm86 mode. In this mode, on vmentry, the processor applies specific checks to guest segment register state. These are listed in SDM Vol 3B, but they include checking that segment selector equals segment base address shifted right four bit positions, for example. Clearly the segment state in the dump you emailed is not valid for vm86 mode. Quite possibly PointSec doesn't expect to be in vm86 mode at all, and something may have gone wrong to set that bit in EFLAGS. But it's hard to say at arm's length.

 -- Keir

Quoted 372 lines

Tom

2009/4/22 Keir Fraser <[email protected]>

Quoted 368 lines

Then it probably is a mis-emulation somewhere down the line. Unfortunately that could be hard to track down, even if we had PointSec software to hand, which we do not.

 -- Keir

Quoted 358 lines · Tom Rotenberg

Well, just tried this patch, and it doesn't seem to work. I get the following error:

(XEN) HVM1: Booting from 0000:7c00
(XEN) Failed vm entry (exit reason 0x80000021) caused by invalid guest state
(0).
(XEN) ************* VMCS Area **************
(XEN) *** Guest State ***
(XEN) CR0: actual=0x0000000080010039, shadow=0x0000000080000019, gh_mask=ffffffffffffffff
(XEN) CR4: actual=0x0000000000002060, shadow=0x0000000000000000, gh_mask=ffffffffffffffff
(XEN) CR3: actual=0x000000000a22fa20, target_count=0
(XEN)      target0=0000000000000000, target1=0000000000000000 (XEN)      target2=0000000000000000, target3=0000000000000000 (XEN) RSP = 0x0000000000000080 (0x0000000000000080)  RIP = 0x000000000000002a
(0x000000000000002a)
(XEN) RFLAGS=0x0000000000023202 (0x0000000000023202)  DR7 = 0x0000000000000400
(XEN) Sysenter RSP=0000000000000000 CS:RIP=0000:0000000000000000 (XEN) CS: sel=0x0060, attr=0x0c09b, limit=0xffffffff, base=0x0000000000200000
(XEN) DS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) SS: sel=0x0070, attr=0x0c093, limit=0xfc000fff, base=0x000000000020ba62
(XEN) ES: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) FS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) GS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) GDTR:                           limit=0x00001dd8, base=0x0000000000200000
(XEN) LDTR: sel=0x0000, attr=0x1c000, limit=0xffffffff, base=0x0000000000000000
(XEN) IDTR:                           limit=0x00000188, base=0x0000000000201df0
(XEN) TR: sel=0x0058, attr=0x0008b, limit=0x0000ffff, base=0x0000000000201ff2
(XEN) Guest PAT = 0x0000000000000000
(XEN) TSC Offset = ffffffe2242f086e
(XEN) DebugCtl=0000000000000000 DebugExceptions=0000000000000000 (XEN) Interruptibility=0001 ActivityState=0000
(XEN) *** Host State ***
(XEN) RSP = 0xffff83007e4f7fa0  RIP = 0xffff828c8019aa20 (XEN) CS=e008 DS=0000 ES=0000 FS=0000 GS=0000 SS=0000 TR=e040 (XEN) FSBase=0000000000000000 GSBase=0000000000000000 TRBase=ffff828c802a8b00
(XEN) GDTBase=ffff83007e9a3000 IDTBase=ffff83007e62e010 (XEN) CR0=0000000080050033 CR3=000000007cfd8000 CR4=00000000000026f0 (XEN) Sysenter RSP=ffff83007e4f7fd0 CS:RIP=e008:ffff828c801c7290 (XEN) Host PAT = 0x0000000000000000
(XEN) *** Control State ***
(XEN) PinBased=0000003f CPUBased=b6a1e7fe SecondaryExec=00000041 (XEN) EntryControls=000011ff ExitControls=0003efff
(XEN) ExceptionBitmap=00044080
(XEN) VMEntry: intr_info=80000b0b errcode=00001eac ilen=00000000 (XEN) VMExit: intr_info=00000000 errcode=00008000 ilen=00000000 (XEN)         reason=80000021 qualification=00000000
(XEN) IDTVectoring: info=00000000 errcode=00000000
(XEN) TPR Threshold = 0x00
(XEN) EPT pointer = 0x0000000000000000
(XEN) Virtual processor ID = 0x0000
(XEN) **************************************
(XEN) domain_crash called from vmx.c:2218
(XEN) Domain 1 (vcpu#0) crashed on cpu#1:
(XEN) ----[ Xen-3.4.0-rc3-pre  x86_64  debug=n  Not tainted ]---- (XEN) CPU:    1
(XEN) RIP:    0060:[<000000000000002a>]
(XEN) RFLAGS: 0000000000023202   CONTEXT: hvm guest
(XEN) rax: 0000000000000007   rbx: 0000000000001490   rcx:
0000000000000000
(XEN) rdx: 0000000000001da8   rsi: 0000000000000000   rdi:
0000000000000000
(XEN) rbp: 0000000000008ebf   rsp: 0000000000000080   r8:
0000000000000000
(XEN) r9:  0000000000000000   r10: 0000000000000000   r11:
0000000000000000
(XEN) r12: 0000000000000000   r13: 0000000000000000   r14:
0000000000000000
(XEN) r15: 0000000000000000   cr0: 0000000080000019   cr4:
0000000000000000
(XEN) cr3: 0000000001443000   cr2: 0000000000000000
(XEN) ds: 0068   es: 0068   fs: 0068   gs: 0068   ss: 0070   cs: 0060

Any ideas?

Tom

2009/4/22 Keir Fraser <[email protected]>

Quoted 262 lines

That should do it.

 K.

Quoted 253 lines · Tom Rotenberg

Keir,
Just to make sure, i am using the following patch, in order to disable the
vm86 acceleration:

diff -r cdc044f665dc xen/arch/x86/hvm/vmx/vmx.c

xen/arch/x86/hvm/vmx/vmx.c    Wed Apr 22 17:03:20 2009 +0300 renamed from xen/arch/x86/hvm/vmx/vmx.c    Wed Apr 22 11:26:37 2009 +0100 +0 -0
@@ -829,7 +829,7 @@


         if ( seg == x86_seg_tr )
         {
-            if ( v->domain->arch.hvm_domain.params[HVM_PARAM_VM86_TSS] )
+            if (0)
             {
                 sel = 0;
                 attr = vm86_tr_attr;

Is this OK?

Tom

2009/4/22 Keir Fraser <[email protected]>

Quoted 228 lines

Yes, the safest way to be sure is probably to replace the if() statement
in
vmx_set_segment_register() that tests HVM_PARAM_VM86_TSS with if(0). That
is
the only place in Xen that checks HVM_PARAM_VM86_TSS. Then you can re-build/install Xen and be sure that vm86 accel must be disabled.

 -- Keir

Quoted 213 lines · Tom Rotenberg

So, do u suggest, that i will set HVM_PARAM_VM86_TSS to 0, and re-check
it?

2009/4/22 Tim Deegan <[email protected]>

Quoted 207 lines
Quoted 6 lines · Keir Fraser

It could be an issue with the vm86 acceleration, possibly. I'm pretty
sure
the guest would have to IRET from protected mode to enter vm86 mode itself,
and we don't emulate that. Tim: what would we need to do to disable

Quoted 8 lines

the
vm86
acceleration for testing purposes? You suggested not setting VM86_TSS
param
from hvmloader, but I couldn't convince myself what effect that would
actually have as the logic in Xen is non-trivial.

Yes; if HVM_PARAM_VM86_TSS is zero, vmx_set_segment_register() will always set the tss bit in the bitmap of segments that aren't safe to enter VM86 with.

Tim.

Quoted 180 lines

 -- Keir

Quoted 172 lines · Tom Rotenberg

Tim,

so what does it mean? could it be that we have a bug in the real mode
emulation, which causes the segment state to be invalid (maybe it's because
of
a bug in the patch that Keir made for me, which emulated the LLDT, and
the
LTR
instructions)?

Keir suggested to trace back where the problem (segment state) occured,
and
from there to try and find the bug which caused it. Do u have any better
suggestion for solving this?

Tom

2009/4/22 Tim Deegan <[email protected]>

Quoted 148 lines

At 13:39 +0100 on 22 Apr (1240407546), Tom Rotenberg wrote:
Keir,

I have tried your latest patch, and it looks like now it passes
the
emulation problem. However,  now the domain crashes with the
following
error:

(XEN) HVM1: Booting from 0000:7c00
(XEN) Failed vm entry (exit reason 0x80000021) caused by invalid
guest
state
(0).
(XEN) ************* VMCS Area **************
(XEN) *** Guest State ***
(XEN) CR0: actual=0x0000000080010039, shadow=0x0000000080000019,
gh_mask=ffffffffffffffff
(XEN) CR4: actual=0x0000000000002060, shadow=0x0000000000000000,
gh_mask=ffffffffffffffff
(XEN) CR3: actual=0x000000000a213a20, target_count=0
(XEN)      target0=0000000000000000, target1=0000000000000000
(XEN)      target2=0000000000000000, target3=0000000000000000
(XEN) RSP = 0x0000000000000080 (0x0000000000000080)  RIP =
0x000000000000002a (0x000000000000002a)
(XEN) RFLAGS=0x0000000000023202 (0x0000000000023202)  DR7 =
0x0000000000000400

Looks like we're trying to VMENTER in virtual 8086 mode but
without
tidying up the segment state.  That could either be the guest
entering
virtual 8086 mode itself or Xen entering vitrual 8086 mode to
emulate
real mode, but Xen is always careful to make the segment state
agree
with Intel's rather strict requrements when it does that.

Tim.

(XEN) Sysenter RSP=0000000000000000 CS:RIP=0000:0000000000000000
(XEN) CS: sel=0x0060, attr=0x0c09b, limit=0xffffffff,
base=0x0000000000200000
(XEN) DS: sel=0x0068, attr=0x0c093, limit=0xffffffff,
base=0x0000000000200000
(XEN) SS: sel=0x0070, attr=0x0c093, limit=0xfc000fff,
base=0x000000000020ba62
(XEN) ES: sel=0x0068, attr=0x0c093, limit=0xffffffff,
base=0x0000000000200000
(XEN) FS: sel=0x0068, attr=0x0c093, limit=0xffffffff,
base=0x0000000000200000
(XEN) GS: sel=0x0068, attr=0x0c093, limit=0xffffffff,
base=0x0000000000200000
(XEN) GDTR:                           limit=0x00001dd8,
base=0x0000000000200000
(XEN) LDTR: sel=0x0000, attr=0x1c000, limit=0xffffffff,
base=0x0000000000000000
(XEN) IDTR:                           limit=0x00000188,
base=0x0000000000201df0
(XEN) TR: sel=0x0058, attr=0x0008b, limit=0x0000ffff,
base=0x0000000000201ff2
(XEN) Guest PAT = 0x0000000000000000
(XEN) TSC Offset = ffffffe4920110b7
(XEN) DebugCtl=0000000000000000 DebugExceptions=0000000000000000
(XEN) Interruptibility=0001 ActivityState=0000
(XEN) *** Host State ***
(XEN) RSP = 0xffff83007e4f7fa0  RIP = 0xffff828c8019aa20
(XEN) CS=e008 DS=0000 ES=0000 FS=0000 GS=0000 SS=0000 TR=e040
(XEN) FSBase=0000000000000000 GSBase=0000000000000000
TRBase=ffff828c802a8b00
(XEN) GDTBase=ffff83007e9a3000 IDTBase=ffff83007e62e010
(XEN) CR0=0000000080050033 CR3=000000007cfdc000
CR4=00000000000026f0
(XEN) Sysenter RSP=ffff83007e4f7fd0 CS:RIP=e008:ffff828c801c7290
(XEN) Host PAT = 0x0000000000000000
(XEN) *** Control State ***
(XEN) PinBased=0000003f CPUBased=b6a1e7fe SecondaryExec=00000041
(XEN) EntryControls=000011ff ExitControls=0003efff
(XEN) ExceptionBitmap=00044080
(XEN) VMEntry: intr_info=80000b0b errcode=00001eac ilen=00000000
(XEN) VMExit: intr_info=00000000 errcode=00008000 ilen=00000000
(XEN)         reason=80000021 qualification=00000000
(XEN) IDTVectoring: info=00000000 errcode=00000000
(XEN) TPR Threshold = 0x00
(XEN) EPT pointer = 0x0000000000000000
(XEN) Virtual processor ID = 0x0000
(XEN) **************************************
(XEN) domain_crash called from vmx.c:2218
(XEN) Domain 1 (vcpu#0) crashed on cpu#1:
(XEN) ----[ Xen-3.4.0-rc3-pre  x86_64  debug=n  Not tainted ]----
(XEN) CPU:    1
(XEN) RIP:    0060:[<000000000000002a>]
(XEN) RFLAGS: 0000000000023202   CONTEXT: hvm guest
(XEN) rax: 0000000000000007   rbx: 0000000000001490   rcx:
0000000000000000
(XEN) rdx: 0000000000001da8   rsi: 0000000000000000   rdi:
0000000000000000
(XEN) rbp: 0000000000008ebf   rsp: 0000000000000080   r8:
 0000000000000000
(XEN) r9:  0000000000000000   r10: 0000000000000000   r11:
0000000000000000
(XEN) r12: 0000000000000000   r13: 0000000000000000   r14:
0000000000000000
(XEN) r15: 0000000000000000   cr0: 0000000080000019   cr4:
0000000000000000
(XEN) cr3: 0000000001443000   cr2: 0000000000000000
(XEN) ds: 0068   es: 0068   fs: 0068   gs: 0068   ss: 0070   cs:
0060

Could it be, that the real mode emulation code has a bug? What
does
this
error means?

Tom

2009/4/22 Keir Fraser
<[email protected]<mailto:[email protected]>>
On 22/04/2009 12:18, "Tom Rotenberg"
<[email protected]<mailto:[email protected]>> wrote:

Keir,

I have applied your patch, and it seemed to work. However, the
domain
still
crashes, and now it looks like it's because of the 'LTR'
instruction.

Try the attached patch. It replaces the one I sent last time, and
emulates
both LLDT and LTR.

 -- Keir

Content-Description: ATT00001.txt
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

--
Tim Deegan <[email protected]>
Principal Software Engineer, Citrix Systems (R&D) Ltd.
[Company #02300071, SL9 0DZ, UK.]

--
Tim Deegan <[email protected]>
Principal Software Engineer, Citrix Systems (R&D) Ltd. [Company #02300071, SL9 0DZ, UK.]

#23 lore raw

OK.

BTW - i am starting to digg this up, and i saw, that the LLDT instruction was done with value of 0, meaning (according to Intel spec), to mark the LDTR as invalid.
After that the LTR instruction was done with value (AX) of 0x50.

However, from the VMCS dump, i saw data, which doesn't seem compatible with this, as the LDTR sellector is indeed 0, but has attributes and limit different from zero (although it should have been totaly disabled, by the LLDT, no?).

And more important, the TR selector is 0x58, although from the LTR, it was supposed to be 0x50, no?
(of-course it's possible that there were other instructions who changed it back, however, i am wondering if there is a problem here).

Tom

2009/4/23 Keir Fraser <[email protected]>

Quoted 414 lines

I don't think we have anything obvious for dealing with single stepping of real mode and 16-bit protected mode. Not to mention that sometimes these bugs occur after execution of many thousands of instructions, which makes a single step approach impractical.

-- Keir

Quoted 3 lines · Tom Rotenberg

Keir,

Is there any tool, which allows debugging step by step of the boot

sequence

Quoted 1 line

(starting from the point which the hvmloader transfers control to the

MBR)?

Quoted 1 line

If there is such tool, i will be able to debug it step by step, and

compare it

Quoted 10 lines

to a real machine, and thus, hopefully find the bug.

Tom

2009/4/22 Keir Fraser <[email protected]>

Quoted 5 lines · Tom Rotenberg
Quoted 4 lines

So, do u have any suggestion for me, on how to advance with this issue? should
i debug the real mode emulation myself in order to track it down? will

u be

Quoted 5 lines
Quoted 5 lines
Quoted 1 line

able top assist me in any way with this issue?

If specific questions arise then certainly yes.

Quoted 1 line

BTW - what is exactly the problem which causes this exception from the

CPU?

Quoted 1 line
Quoted 1 line
Quoted 1 line

Tim mentioned something about segment state - can u please elaborate on

this

Quoted 3 lines
Quoted 3 lines
Quoted 1 line

issue?

Bit 17 in EFLAGS is set, meaning the guest is in vm86 mode. In this

mode, on

Quoted 4 lines
Quoted 4 lines

vmentry, the processor applies specific checks to guest segment register state. These are listed in SDM Vol 3B, but they include checking that segment selector equals segment base address shifted right four bit positions, for example. Clearly the segment state in the dump you

emailed is

Quoted 10 lines
Quoted 10 lines

not valid for vm86 mode. Quite possibly PointSec doesn't expect to be in vm86 mode at all, and something may have gone wrong to set that bit in EFLAGS. But it's hard to say at arm's length.

-- Keir

Quoted 4 lines

Tom

2009/4/22 Keir Fraser <[email protected]>

Quoted 1 line

Then it probably is a mis-emulation somewhere down the line.

Unfortunately

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

that could be hard to track down, even if we had PointSec software to

hand,

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

which we do not.

-- Keir

Quoted 5 lines · Tom Rotenberg

Well, just tried this patch, and it doesn't seem to work. I get the following error:

(XEN) HVM1: Booting from 0000:7c00
(XEN) Failed vm entry (exit reason 0x80000021) caused by invalid

guest

Quoted 96 lines
Quoted 96 lines
Quoted 96 lines
Quoted 96 lines
Quoted 96 lines

state
(0).
(XEN) ************* VMCS Area **************
(XEN) *** Guest State ***
(XEN) CR0: actual=0x0000000080010039, shadow=0x0000000080000019, gh_mask=ffffffffffffffff
(XEN) CR4: actual=0x0000000000002060, shadow=0x0000000000000000, gh_mask=ffffffffffffffff
(XEN) CR3: actual=0x000000000a22fa20, target_count=0
(XEN) target0=0000000000000000, target1=0000000000000000
(XEN) target2=0000000000000000, target3=0000000000000000
(XEN) RSP = 0x0000000000000080 (0x0000000000000080) RIP = 0x000000000000002a
(0x000000000000002a)
(XEN) RFLAGS=0x0000000000023202 (0x0000000000023202) DR7 = 0x0000000000000400
(XEN) Sysenter RSP=0000000000000000 CS:RIP=0000:0000000000000000 (XEN) CS: sel=0x0060, attr=0x0c09b, limit=0xffffffff, base=0x0000000000200000
(XEN) DS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) SS: sel=0x0070, attr=0x0c093, limit=0xfc000fff, base=0x000000000020ba62
(XEN) ES: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) FS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) GS: sel=0x0068, attr=0x0c093, limit=0xffffffff, base=0x0000000000200000
(XEN) GDTR: limit=0x00001dd8,
base=0x0000000000200000
(XEN) LDTR: sel=0x0000, attr=0x1c000, limit=0xffffffff, base=0x0000000000000000
(XEN) IDTR: limit=0x00000188,
base=0x0000000000201df0
(XEN) TR: sel=0x0058, attr=0x0008b, limit=0x0000ffff, base=0x0000000000201ff2
(XEN) Guest PAT = 0x0000000000000000
(XEN) TSC Offset = ffffffe2242f086e
(XEN) DebugCtl=0000000000000000 DebugExceptions=0000000000000000 (XEN) Interruptibility=0001 ActivityState=0000
(XEN) *** Host State ***
(XEN) RSP = 0xffff83007e4f7fa0 RIP = 0xffff828c8019aa20 (XEN) CS=e008 DS=0000 ES=0000 FS=0000 GS=0000 SS=0000 TR=e040 (XEN) FSBase=0000000000000000 GSBase=0000000000000000 TRBase=ffff828c802a8b00
(XEN) GDTBase=ffff83007e9a3000 IDTBase=ffff83007e62e010 (XEN) CR0=0000000080050033 CR3=000000007cfd8000 CR4=00000000000026f0 (XEN) Sysenter RSP=ffff83007e4f7fd0 CS:RIP=e008:ffff828c801c7290 (XEN) Host PAT = 0x0000000000000000
(XEN) *** Control State ***
(XEN) PinBased=0000003f CPUBased=b6a1e7fe SecondaryExec=00000041 (XEN) EntryControls=000011ff ExitControls=0003efff
(XEN) ExceptionBitmap=00044080
(XEN) VMEntry: intr_info=80000b0b errcode=00001eac ilen=00000000 (XEN) VMExit: intr_info=00000000 errcode=00008000 ilen=00000000
(XEN) reason=80000021 qualification=00000000
(XEN) IDTVectoring: info=00000000 errcode=00000000
(XEN) TPR Threshold = 0x00
(XEN) EPT pointer = 0x0000000000000000
(XEN) Virtual processor ID = 0x0000
(XEN) **************************************
(XEN) domain_crash called from vmx.c:2218
(XEN) Domain 1 (vcpu#0) crashed on cpu#1:
(XEN) ----[ Xen-3.4.0-rc3-pre x86_64 debug=n Not tainted ]----
(XEN) CPU: 1
(XEN) RIP: 0060:[<000000000000002a>]
(XEN) RFLAGS: 0000000000023202 CONTEXT: hvm guest
(XEN) rax: 0000000000000007 rbx: 0000000000001490 rcx:
0000000000000000
(XEN) rdx: 0000000000001da8 rsi: 0000000000000000 rdi:
0000000000000000
(XEN) rbp: 0000000000008ebf rsp: 0000000000000080 r8:
0000000000000000
(XEN) r9: 0000000000000000 r10: 0000000000000000 r11:
0000000000000000
(XEN) r12: 0000000000000000 r13: 0000000000000000 r14:
0000000000000000
(XEN) r15: 0000000000000000 cr0: 0000000080000019 cr4:
0000000000000000
(XEN) cr3: 0000000001443000 cr2: 0000000000000000
(XEN) ds: 0068 es: 0068 fs: 0068 gs: 0068 ss: 0070 cs: 0060

Any ideas?

Tom

2009/4/22 Keir Fraser <[email protected]>

Quoted 6 lines

That should do it.

K.

On 22/04/2009 15:04, "Tom Rotenberg" <[email protected]>

Quoted 3 lines · wrote:
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Keir,
Just to make sure, i am using the following patch, in order to

disable

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

xen/arch/x86/hvm/vmx/vmx.c Wed Apr 22 17:03:20 2009 +0300 line 832

Quoted 11 lines

the
vm86 acceleration:

diff -r cdc044f665dc xen/arch/x86/hvm/vmx/vmx.c

xen/arch/x86/hvm/vmx/vmx.c Wed Apr 22 17:03:20 2009 +0300 renamed from xen/arch/x86/hvm/vmx/vmx.c Wed Apr 22 11:26:37 2009 +0100 +0 -1
@@ -829,7 +829,7 @@
 
         if ( seg == x86_seg_tr )
         {
-            if (

v->domain->arch.hvm_domain.params[HVM_PARAM_VM86_TSS]

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
xen/arch/x86/hvm/vmx/vmx.c Wed Apr 22 17:03:20 2009 +0300 renamed from xen/arch/x86/hvm/vmx/vmx.c Wed Apr 22 11:26:37 2009 +0100 +1 -0
 )
+            if (0)
             {
                 sel = 0;
                 attr = vm86_tr_attr;

Is this OK?

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Tom

2009/4/22 Keir Fraser <[email protected]>

Quoted 4 lines

Yes, the safest way to be sure is probably to replace the if() statement
in
vmx_set_segment_register() that tests HVM_PARAM_VM86_TSS with

if(0).

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

That
is
the only place in Xen that checks HVM_PARAM_VM86_TSS. Then you can re-build/install Xen and be sure that vm86 accel must be disabled.

-- Keir

On 22/04/2009 14:52, "Tom Rotenberg" <[email protected]>

Quoted 11 lines · wrote:
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

So, do u suggest, that i will set HVM_PARAM_VM86_TSS to 0, and re-check
it?

2009/4/22 Tim Deegan <[email protected]>

Quoted 5 lines
Quoted 4 lines · Keir Fraser

It could be an issue with the vm86 acceleration, possibly. I'm pretty
sure
the guest would have to IRET from protected mode to enter vm86

mode

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

itself,
and we don't emulate that. Tim: what would we need to do to

disable

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 8 lines

the
vm86
acceleration for testing purposes? You suggested not setting VM86_TSS
param
from hvmloader, but I couldn't convince myself what effect that would
actually have as the logic in Xen is non-trivial.

Yes; if HVM_PARAM_VM86_TSS is zero, vmx_set_segment_register()

will

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

always set the tss bit in the bitmap of segments that aren't

safe to

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

enter VM86 with.

Tim.

Quoted 1 line
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

-- Keir

Quoted 3 lines · Tom Rotenberg

Tim,

so what does it mean? could it be that we have a bug in the

real

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

mode
emulation, which causes the segment state to be invalid (maybe

it's

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

because
of
a bug in the patch that Keir made for me, which emulated the

LLDT,

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

and
the
LTR
instructions)?

Keir suggested to trace back where the problem (segment state)
occured,
and
from there to try and find the bug which caused it. Do u have

any

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

better
suggestion for solving this?

Tom

2009/4/22 Tim Deegan <[email protected]>
At 13:39 +0100 on 22 Apr (1240407546), Tom Rotenberg wrote:
Keir,

I have tried your latest patch, and it looks like now it

passes

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

the
emulation problem. However, now the domain crashes with the
following
error:

(XEN) HVM1: Booting from 0000:7c00
(XEN) Failed vm entry (exit reason 0x80000021) caused by

invalid

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

guest
state
(0).
(XEN) ************* VMCS Area **************
(XEN) *** Guest State ***
(XEN) CR0: actual=0x0000000080010039,

shadow=0x0000000080000019,

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

gh_mask=ffffffffffffffff
(XEN) CR4: actual=0x0000000000002060,

shadow=0x0000000000000000,

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

gh_mask=ffffffffffffffff
(XEN) CR3: actual=0x000000000a213a20, target_count=0
(XEN) target0=0000000000000000, target1=0000000000000000
(XEN) target2=0000000000000000, target3=0000000000000000
(XEN) RSP = 0x0000000000000080 (0x0000000000000080) RIP =
0x000000000000002a (0x000000000000002a)
(XEN) RFLAGS=0x0000000000023202 (0x0000000000023202) DR7 =
0x0000000000000400

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Looks like we're trying to VMENTER in virtual 8086 mode but
without
tidying up the segment state. That could either be the guest
entering
virtual 8086 mode itself or Xen entering vitrual 8086 mode to
emulate
real mode, but Xen is always careful to make the segment

state

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

agree
with Intel's rather strict requrements when it does that.

Tim.

(XEN) Sysenter RSP=0000000000000000

CS:RIP=0000:0000000000000000

Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines

(XEN) CS: sel=0x0060, attr=0x0c09b, limit=0xffffffff,
base=0x0000000000200000
(XEN) DS: sel=0x0068, attr=0x0c093, limit=0xffffffff,
base=0x0000000000200000
(XEN) SS: sel=0x0070, attr=0x0c093, limit=0xfc000fff,
base=0x000000000020ba62
(XEN) ES: sel=0x0068, attr=0x0c093, limit=0xffffffff,
base=0x0000000000200000
(XEN) FS: sel=0x0068, attr=0x0c093, limit=0xffffffff,
base=0x0000000000200000
(XEN) GS: sel=0x0068, attr=0x0c093, limit=0xffffffff,
base=0x0000000000200000
(XEN) GDTR: limit=0x00001dd8,
base=0x0000000000200000
(XEN) LDTR: sel=0x0000, attr=0x1c000, limit=0xffffffff,

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

base=0x0000000000000000
(XEN) IDTR: limit=0x00000188,
base=0x0000000000201df0
(XEN) TR: sel=0x0058, attr=0x0008b, limit=0x0000ffff,
base=0x0000000000201ff2
(XEN) Guest PAT = 0x0000000000000000
(XEN) TSC Offset = ffffffe4920110b7
(XEN) DebugCtl=0000000000000000

DebugExceptions=0000000000000000

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

(XEN) Interruptibility=0001 ActivityState=0000
(XEN) *** Host State ***
(XEN) RSP = 0xffff83007e4f7fa0 RIP = 0xffff828c8019aa20
(XEN) CS=e008 DS=0000 ES=0000 FS=0000 GS=0000 SS=0000 TR=e040
(XEN) FSBase=0000000000000000 GSBase=0000000000000000
TRBase=ffff828c802a8b00
(XEN) GDTBase=ffff83007e9a3000 IDTBase=ffff83007e62e010
(XEN) CR0=0000000080050033 CR3=000000007cfdc000
CR4=00000000000026f0
(XEN) Sysenter RSP=ffff83007e4f7fd0

CS:RIP=e008:ffff828c801c7290

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

(XEN) Host PAT = 0x0000000000000000
(XEN) *** Control State ***
(XEN) PinBased=0000003f CPUBased=b6a1e7fe

SecondaryExec=00000041

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

(XEN) EntryControls=000011ff ExitControls=0003efff
(XEN) ExceptionBitmap=00044080
(XEN) VMEntry: intr_info=80000b0b errcode=00001eac

ilen=00000000

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

(XEN) VMExit: intr_info=00000000 errcode=00008000

ilen=00000000

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

(XEN) reason=80000021 qualification=00000000
(XEN) IDTVectoring: info=00000000 errcode=00000000
(XEN) TPR Threshold = 0x00
(XEN) EPT pointer = 0x0000000000000000
(XEN) Virtual processor ID = 0x0000
(XEN) **************************************
(XEN) domain_crash called from vmx.c:2218
(XEN) Domain 1 (vcpu#0) crashed on cpu#1:
(XEN) ----[ Xen-3.4.0-rc3-pre x86_64 debug=n Not tainted

]----

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

(XEN) CPU: 1
(XEN) RIP: 0060:[<000000000000002a>]
(XEN) RFLAGS: 0000000000023202 CONTEXT: hvm guest
(XEN) rax: 0000000000000007 rbx: 0000000000001490 rcx:
0000000000000000
(XEN) rdx: 0000000000001da8 rsi: 0000000000000000 rdi:
0000000000000000
(XEN) rbp: 0000000000008ebf rsp: 0000000000000080 r8:
0000000000000000

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

(XEN) r9: 0000000000000000 r10: 0000000000000000 r11:
0000000000000000
(XEN) r12: 0000000000000000 r13: 0000000000000000 r14:
0000000000000000
(XEN) r15: 0000000000000000 cr0: 0000000080000019 cr4:
0000000000000000
(XEN) cr3: 0000000001443000 cr2: 0000000000000000
(XEN) ds: 0068 es: 0068 fs: 0068 gs: 0068 ss: 0070

cs:

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

0060

Could it be, that the real mode emulation code has a bug?

What

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

does
this
error means?

Tom

2009/4/22 Keir Fraser
<[email protected]<mailto:[email protected]

On 22/04/2009 12:18, "Tom Rotenberg"
<[email protected]<mailto:[email protected]>>

Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Keir,

I have applied your patch, and it seemed to work. However,

Quoted 49 lines

the

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

domain
still
crashes, and now it looks like it's because of the 'LTR'
instruction.

Try the attached patch. It replaces the one I sent last time,

and

Quoted 38 lines
Quoted 37 lines
Quoted 35 lines
Quoted 34 lines
Quoted 32 lines
Quoted 31 lines
Quoted 29 lines
Quoted 28 lines
Quoted 26 lines
Quoted 25 lines
Quoted 13 lines
Quoted 13 lines

emulates
both LLDT and LTR.

-- Keir

Content-Description: ATT00001.txt
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

Quoted 7 lines
Quoted 5 lines

--
Tim Deegan <[email protected]>
Principal Software Engineer, Citrix Systems (R&D) Ltd.
[Company #02300071, SL9 0DZ, UK.]

--
Tim Deegan <[email protected]>
Principal Software Engineer, Citrix Systems (R&D) Ltd. [Company #02300071, SL9 0DZ, UK.]

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#24 lore raw
Quoted 4 lines · Tom Rotenberg

However, from the VMCS dump, i saw data, which doesn't seem compatible with this, as the LDTR sellector is indeed 0, but has attributes and limit different from zero (although it should have been totaly disabled, by the LLDT, no?).

The 'unused' flag in the attributes word is set (bit 16) so LDTR is okay.

Quoted 2 lines

And more important, the TR selector is 0x58, although from the LTR, it was supposed to be 0x50, no?

If 0x50 was loaded then the selector should certainly be 0x50.

-- Keir

Quoted 2 lines

(of-course it's possible that there were other instructions who changed it back, however, i am wondering if there is a problem here).

#25 lore raw

About the TR, i have re-checked it, and it seems like the TR value is still 0x58, althoug the LTR operation put 0x50 into it. Since, i looked at the LTR code you sent me, and it seems ok, i tend to suspect, that there was some kind of (hardware) task switch, which changed the TR value without me knowing, is it possible? because otherwise, i can't really explain why the TR value is different than what was loaded from the LTR operation...

BTW - how can i track what was the previous VMEXIT before this last VMENTRY which caused the exception? i think, that probably the last VMEXIT caused the "change" to vm86 mode, and this is waht causes the problem...

Tom

2009/4/23 Keir Fraser <[email protected]>

Quoted 12 lines · Tom Rotenberg
Quoted 2 lines

However, from the VMCS dump, i saw data, which doesn't seem compatible

with

Quoted 3 lines

this, as the LDTR sellector is indeed 0, but has attributes and limit different from zero (although it should have been totaly disabled, by the LLDT, no?).

The 'unused' flag in the attributes word is set (bit 16) so LDTR is okay.

Quoted 1 line

And more important, the TR selector is 0x58, although from the LTR, it

was

Quoted 12 lines
Quoted 1 line

supposed to be 0x50, no?

If 0x50 was loaded then the selector should certainly be 0x50.

-- Keir

Quoted 1 line

(of-course it's possible that there were other instructions who changed

it

Quoted 1 line

back, however, i am wondering if there is a problem here).

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#26 lore raw

All task switches are emulated, so you can add tracing to hvm_task_switch() to check if a switch has occurred. An alternative is that the guest did another LTR while not being emulated?

If you want to remember the last VMEXIT, you¹ll have to add code to store state away somewhere to pick up on the next VMENTRY.

-- Keir

Quoted 7 lines · Tom Rotenberg

About the TR, i have re-checked it, and it seems like the TR value is still 0x58, althoug the LTR operation put 0x50 into it. Since, i looked at the LTR code you sent me, and it seems ok, i tend to suspect, that there was some kind of (hardware) task switch, which changed the TR value without me knowing, is it possible? because otherwise, i can't really explain why the TR value is different than what was loaded from the LTR operation...

Quoted 29 lines

BTW - how can i track what was the previous VMEXIT before this last VMENTRY which caused the exception? i think, that probably the last VMEXIT caused the "change" to vm86 mode, and this is waht causes the problem...

Tom

2009/4/23 Keir Fraser <[email protected]>

Quoted 21 lines · Tom Rotenberg
Quoted 6 lines
Quoted 2 lines

However, from the VMCS dump, i saw data, which doesn't seem compatible

with

Quoted 3 lines

this, as the LDTR sellector is indeed 0, but has attributes and limit different from zero (although it should have been totaly disabled, by the LLDT, no?).

The 'unused' flag in the attributes word is set (bit 16) so LDTR is okay.

Quoted 2 lines
Quoted 2 lines

And more important, the TR selector is 0x58, although from the LTR, it was supposed to be 0x50, no?

If 0x50 was loaded then the selector should certainly be 0x50.

 -- Keir

Quoted 2 lines
Quoted 2 lines

(of-course it's possible that there were other instructions who changed it back, however, i am wondering if there is a problem here).

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#27 lore raw

Keir,

After further testing, it seems like the flow of events were like this:
there was a VMEXIT with the reason of task switch, which changed to vm86mode (!), and upon trying to resume from this vmexit, the cpu raised an exception.

And the question is why and how did the task switch caused the vm86 mode to be turned on? is it even legal?

Tom

2009/4/23 Keir Fraser <[email protected]>

Quoted 39 lines

All task switches are emulated, so you can add tracing to
hvm_task_switch() to check if a switch has occurred. An alternative is that the guest did another LTR while not being emulated?

If you want to remember the last VMEXIT, you’ll have to add code to store state away somewhere to pick up on the next VMENTRY.

-- Keir

On 23/04/2009 15:08, "Tom Rotenberg" <[email protected]> wrote:

About the TR, i have re-checked it, and it seems like the TR value is still 0x58, althoug the LTR operation put 0x50 into it. Since, i looked at the LTR code you sent me, and it seems ok, i tend to suspect, that there was some kind of (hardware) task switch, which changed the TR value without me knowing, is it possible? because otherwise, i can't really explain why the TR value is different than what was loaded from the LTR operation...

BTW - how can i track what was the previous VMEXIT before this last VMENTRY which caused the exception? i think, that probably the last VMEXIT caused the "change" to vm86 mode, and this is waht causes the problem...

Tom

2009/4/23 Keir Fraser <[email protected]>

Quoted 1 line · Tom Rotenberg

However, from the VMCS dump, i saw data, which doesn't seem compatible

with

Quoted 3 lines

this, as the LDTR sellector is indeed 0, but has attributes and limit different from zero (although it should have been totaly disabled, by the LLDT, no?).

The 'unused' flag in the attributes word is set (bit 16) so LDTR is okay.

Quoted 1 line

And more important, the TR selector is 0x58, although from the LTR, it

was

Quoted 13 lines
Quoted 1 line

supposed to be 0x50, no?

If 0x50 was loaded then the selector should certainly be 0x50.

-- Keir

Quoted 1 line

(of-course it's possible that there were other instructions who changed

it

Quoted 1 line

back, however, i am wondering if there is a problem here).

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#28 lore raw
Quoted 6 lines · Tom Rotenberg

Keir,

After further testing, it seems like the flow of events were like this: there was a VMEXIT with the reason of task switch, which changed to vm86mode (!), and upon trying to resume from this vmexit, the cpu raised an exception.

And the question is why and how did the task switch caused the vm86 mode to be turned on? is it even legal?

Yes, task-switching into vm86 mode is legal; ISTR it and IRET are the only ways mentioned in the SDMs of getting into vm86.

Looks like Xen doesn't support it, though. It would need special handling of the segment state to get round the extra restrictions that Intel imposed on VMENTER (which are stricter than the limits on using vm86 mode unvirtualized).

Cheers,

Tim.

Quoted 40 lines

Tom

2009/4/23 Keir Fraser <[email protected]<mailto:[email protected]>>
All task switches are emulated, so you can add tracing to hvm_task_switch() to check if a switch has occurred. An alternative is that the guest did another LTR while not being emulated?

If you want to remember the last VMEXIT, you?ll have to add code to store state away somewhere to pick up on the next VMENTRY.

-- Keir

On 23/04/2009 15:08, "Tom Rotenberg" <[email protected]<http://[email protected]>> wrote:

About the TR, i have re-checked it, and it seems like the TR value is still 0x58, althoug the LTR operation put 0x50 into it. Since, i looked at the LTR code you sent me, and it seems ok, i tend to suspect, that there was some kind of (hardware) task switch, which changed the TR value without me knowing, is it possible? because otherwise, i can't really explain why the TR value is different than what was loaded from the LTR operation...

BTW - how can i track what was the previous VMEXIT before this last VMENTRY which caused the exception? i think, that probably the last VMEXIT caused the "change" to vm86 mode, and this is waht causes the problem...

Tom

2009/4/23 Keir Fraser <[email protected]<http://[email protected]>>

Quoted 4 lines · On 23/04/2009 12:44, "Tom Rotenberg" <[email protected]<http://tom.rotenb…

However, from the VMCS dump, i saw data, which doesn't seem compatible with this, as the LDTR sellector is indeed 0, but has attributes and limit different from zero (although it should have been totaly disabled, by the LLDT, no?).

The 'unused' flag in the attributes word is set (bit 16) so LDTR is okay.

Quoted 2 lines

And more important, the TR selector is 0x58, although from the LTR, it was supposed to be 0x50, no?

If 0x50 was loaded then the selector should certainly be 0x50.

-- Keir

Quoted 2 lines

(of-course it's possible that there were other instructions who changed it back, however, i am wondering if there is a problem here).

Signature · 3 lines
Tim Deegan <[email protected]>
Principal Software Engineer, Citrix Systems (R&D) Ltd.
[Company #02300071, SL9 0DZ, UK.]
#29 lore raw

So, do u have any suggestion, on how can i fix this issue?

2009/4/23 Tim Deegan <[email protected]>

Quoted 82 lines
Quoted 3 lines · Tom Rotenberg

Keir,

After further testing, it seems like the flow of events were like this:

there was a VMEXIT with the reason of task switch, which changed to vm86mode (!), and upon trying to resume from this vmexit, the cpu raised an exception.

Quoted 3 lines

And the question is why and how did the task switch caused the vm86 mode to be turned on? is it even legal?

Yes, task-switching into vm86 mode is legal; ISTR it and IRET are the only ways mentioned in the SDMs of getting into vm86.

Looks like Xen doesn't support it, though. It would need special handling of the segment state to get round the extra restrictions that Intel imposed on VMENTER (which are stricter than the limits on using vm86 mode unvirtualized).

Cheers,

Tim.

Quoted 3 lines

Tom

2009/4/23 Keir Fraser <[email protected]<mailto:

[email protected]>>

Quoted 1 line

All task switches are emulated, so you can add tracing to

hvm_task_switch() to check if a switch has occurred. An alternative is that the guest did another LTR while not being emulated?

Quoted 2 lines

If you want to remember the last VMEXIT, you?ll have to add code to store

state away somewhere to pick up on the next VMENTRY.

Quoted 5 lines

-- Keir

On 23/04/2009 15:08, "Tom Rotenberg" <[email protected]<

Quoted 2 lines · http://[email protected]>> wrote:

About the TR, i have re-checked it, and it seems like the TR value is

still 0x58, althoug the LTR operation put 0x50 into it. Since, i looked at the LTR code you sent me, and it seems ok, i tend to suspect, that there was some kind of (hardware) task switch, which changed the TR value without me knowing, is it possible? because otherwise, i can't really explain why the TR value is different than what was loaded from the LTR operation...

Quoted 2 lines

BTW - how can i track what was the previous VMEXIT before this last

VMENTRY which caused the exception? i think, that probably the last VMEXIT caused the "change" to vm86 mode, and this is waht causes the problem...

Quoted 4 lines

Tom

2009/4/23 Keir Fraser <[email protected]<http://keir.fraser@

eu.citrix.com>>

Quoted 1 line

On 23/04/2009 12:44, "Tom Rotenberg" <[email protected]<

Quoted 2 lines · http://[email protected]>> wrote:
Quoted 2 lines

However, from the VMCS dump, i saw data, which doesn't seem compatible

with

Quoted 2 lines
Quoted 2 lines

this, as the LDTR sellector is indeed 0, but has attributes and limit different from zero (although it should have been totaly disabled, by

the

Quoted 5 lines
Quoted 1 line

LLDT, no?).

The 'unused' flag in the attributes word is set (bit 16) so LDTR is okay.

Quoted 1 line

And more important, the TR selector is 0x58, although from the LTR, it

was

Quoted 7 lines
Quoted 1 line

supposed to be 0x50, no?

If 0x50 was loaded then the selector should certainly be 0x50.

-- Keir

Quoted 1 line

(of-course it's possible that there were other instructions who changed

it

Quoted 4 lines
Quoted 1 line

back, however, i am wondering if there is a problem here).

Quoted 5 lines

--
Tim Deegan <[email protected]>
Principal Software Engineer, Citrix Systems (R&D) Ltd. [Company #02300071, SL9 0DZ, UK.]

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#30 lore raw

A task switch reloads on segment registers, so it is impossible to enter vm86 mode with 'bad' segment state even via a task switch.

If the guest really is trying to enter vm86 mode via a task switch (which would be somewhat bizarre, although a valid thing to do) then hvm_load_segment_selector() needs updating to deal with VM86 mode. I'll make a patch.

-- Keir

Quoted 89 lines · Tom Rotenberg

So, do u have any suggestion, on how can i fix this issue?

2009/4/23 Tim Deegan <[email protected]>

Quoted 85 lines
Quoted 9 lines · Tom Rotenberg

Keir,

After further testing, it seems like the flow of events were like this:
there was a VMEXIT with the reason of task switch, which changed to vm86mode (!), and upon trying to resume from this vmexit, the cpu raised an exception.

And the question is why and how did the task switch caused the vm86 mode to be turned on? is it even legal?

Yes, task-switching into vm86 mode is legal; ISTR it and IRET are the only ways mentioned in the SDMs of getting into vm86.

Looks like Xen doesn't support it, though.  It would need special handling of the segment state to get round the extra restrictions that Intel imposed on VMENTER (which are stricter than the limits on using vm86 mode unvirtualized).

Cheers,

Tim.

Quoted 43 lines

Tom

2009/4/23 Keir Fraser <[email protected]<mailto:[email protected]>> All task switches are emulated, so you can add tracing to hvm_task_switch() to check if a switch has occurred. An alternative is that the guest did another LTR while not being emulated?

If you want to remember the last VMEXIT, you?ll have to add code to store state away somewhere to pick up on the next VMENTRY.

 -- Keir

On 23/04/2009 15:08, "Tom Rotenberg" <[email protected]<http://[email protected] <http://gmail.com>

Quoted 1 line
Quoted 1 line

wrote:

About the TR, i have re-checked it, and it seems like the TR value is still 0x58, althoug the LTR operation put 0x50 into it. Since, i looked at the LTR code you sent me, and it seems ok, i tend to suspect, that there was some kind of (hardware) task switch, which changed the TR value without me knowing, is it possible? because otherwise, i can't really explain why the TR value is different than what was loaded from the LTR operation...

BTW - how can i track what was the previous VMEXIT before this last VMENTRY which caused the exception? i think, that probably the last VMEXIT caused the "change" to vm86 mode, and this is waht causes the problem...

Tom

2009/4/23 Keir Fraser <[email protected]<http://[email protected]
<http://eu.citrix.com> >>
On 23/04/2009 12:44, "Tom Rotenberg" <[email protected]<http://[email protected] <http://gmail.com>

Quoted 6 lines
Quoted 1 line

wrote:

However, from the VMCS dump, i saw data, which doesn't seem compatible with this, as the LDTR sellector is indeed 0, but has attributes and limit different from zero (although it should have been totaly disabled, by the LLDT, no?).

Quoted 14 lines

The 'unused' flag in the attributes word is set (bit 16) so LDTR is okay.

Quoted 2 lines

And more important, the TR selector is 0x58, although from the LTR, it was supposed to be 0x50, no?

If 0x50 was loaded then the selector should certainly be 0x50.

 -- Keir

Quoted 2 lines

(of-course it's possible that there were other instructions who changed it back, however, i am wondering if there is a problem here).

--
Tim Deegan <[email protected]>
Principal Software Engineer, Citrix Systems (R&D) Ltd. [Company #02300071, SL9 0DZ, UK.]

#31 lore raw

Patch is attached. It is in addition to the LTR/LLDT patch.

-- Keir

Quoted 105 lines · Keir Fraser

A task switch reloads on segment registers, so it is impossible to enter vm86 mode with 'bad' segment state even via a task switch.

If the guest really is trying to enter vm86 mode via a task switch (which would be somewhat bizarre, although a valid thing to do) then hvm_load_segment_selector() needs updating to deal with VM86 mode. I'll make a patch.

-- Keir

Quoted 92 lines · Tom Rotenberg

So, do u have any suggestion, on how can i fix this issue?

2009/4/23 Tim Deegan <[email protected]>

Quoted 88 lines
Quoted 10 lines · Tom Rotenberg

Keir,

After further testing, it seems like the flow of events were like this:
there was a VMEXIT with the reason of task switch, which changed to vm86mode
(!), and upon trying to resume from this vmexit, the cpu raised an exception.

And the question is why and how did the task switch caused the vm86 mode to be turned on? is it even legal?

Yes, task-switching into vm86 mode is legal; ISTR it and IRET are the only ways mentioned in the SDMs of getting into vm86.

Looks like Xen doesn't support it, though.  It would need special handling of the segment state to get round the extra restrictions that Intel imposed on VMENTER (which are stricter than the limits on using vm86 mode unvirtualized).

Cheers,

Tim.

Quoted 45 lines

Tom

2009/4/23 Keir Fraser <[email protected]<mailto:[email protected]>> All task switches are emulated, so you can add tracing to hvm_task_switch() to check if a switch has occurred. An alternative is that the guest did another LTR while not being emulated?

If you want to remember the last VMEXIT, you?ll have to add code to store state away somewhere to pick up on the next VMENTRY.

 -- Keir

On 23/04/2009 15:08, "Tom Rotenberg" <[email protected]<http://[email protected] <http://gmail.com>

Quoted 1 line
Quoted 1 line

wrote:

About the TR, i have re-checked it, and it seems like the TR value is still 0x58, althoug the LTR operation put 0x50 into it. Since, i looked at the LTR
code you sent me, and it seems ok, i tend to suspect, that there was some kind of (hardware) task switch, which changed the TR value without me knowing, is it possible? because otherwise, i can't really explain why the TR value is different than what was loaded from the LTR operation...

BTW - how can i track what was the previous VMEXIT before this last VMENTRY which caused the exception? i think, that probably the last VMEXIT caused the "change" to vm86 mode, and this is waht causes the problem...

Tom

2009/4/23 Keir Fraser <[email protected]<http://[email protected]
<http://eu.citrix.com> >>
On 23/04/2009 12:44, "Tom Rotenberg" <[email protected]<http://[email protected] <http://gmail.com>

Quoted 7 lines
Quoted 1 line

wrote:

However, from the VMCS dump, i saw data, which doesn't seem compatible with
this, as the LDTR sellector is indeed 0, but has attributes and limit different from zero (although it should have been totaly disabled, by the LLDT, no?).

Quoted 14 lines

The 'unused' flag in the attributes word is set (bit 16) so LDTR is okay.

Quoted 2 lines

And more important, the TR selector is 0x58, although from the LTR, it was supposed to be 0x50, no?

If 0x50 was loaded then the selector should certainly be 0x50.

 -- Keir

Quoted 2 lines

(of-course it's possible that there were other instructions who changed it back, however, i am wondering if there is a problem here).

--
Tim Deegan <[email protected]>
Principal Software Engineer, Citrix Systems (R&D) Ltd. [Company #02300071, SL9 0DZ, UK.]

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#32 lore raw

Keir,

I applied the patch, and it seems it helped a little, however, the domain is still crashing, with the following error:

(XEN) HVM1: Booting from 0000:7c00
(XEN) Failed vm entry (exit reason 0x80000021) caused by invalid guest state (0).
(XEN) ************* VMCS Area **************
(XEN) *** Guest State ***
(XEN) CR0: actual=0x0000000080010039, shadow=0x0000000080000019, gh_mask=ffffffffffffffff
(XEN) CR4: actual=0x0000000000002060, shadow=0x0000000000000000, gh_mask=ffffffffffffffff
(XEN) CR3: actual=0x000000000a211a20, target_count=0
(XEN) target0=0000000000000000, target1=0000000000000000
(XEN) target2=0000000000000000, target3=0000000000000000
(XEN) RSP = 0x0000000000000080 (0x0000000000000080) RIP = 0x000000000000002a (0x000000000000002a)
(XEN) RFLAGS=0x0000000000023202 (0x0000000000023202) DR7 = 0x0000000000000400
(XEN) Sysenter RSP=0000000000000000 CS:RIP=0000:0000000000000000 (XEN) CS: sel=0x14a2, attr=0x000f3, limit=0x0000ffff, base=0x0000000000014a20
(XEN) DS: sel=0x1da8, attr=0x000f3, limit=0x0000ffff, base=0x000000000001da80
(XEN) SS: sel=0x1ea6, attr=0x000f3, limit=0x0000ffff, base=0x000000000001ea60
(XEN) ES: sel=0x1eae, attr=0x000f3, limit=0x0000ffff, base=0x000000000001eae0
(XEN) FS: sel=0x0000, attr=0x000f3, limit=0x0000ffff, base=0x0000000000000000
(XEN) GS: sel=0x0000, attr=0x000f3, limit=0x0000ffff, base=0x0000000000000000
(XEN) GDTR: limit=0x00001dd8,
base=0x0000000000200000
(XEN) LDTR: sel=0x0000, attr=0x000f3, limit=0x0000ffff, base=0x0000000000000000
(XEN) IDTR: limit=0x00000188,
base=0x0000000000201df0
(XEN) TR: sel=0x0058, attr=0x0008b, limit=0x0000ffff, base=0x0000000000201ff2
(XEN) Guest PAT = 0x0000000000000000
(XEN) TSC Offset = ffffffcaa41ccde0
(XEN) DebugCtl=0000000000000000 DebugExceptions=0000000000000000 (XEN) Interruptibility=0001 ActivityState=0000
(XEN) *** Host State ***
(XEN) RSP = 0xffff828c8026ffa0 RIP = 0xffff828c8019aa90
(XEN) CS=e008 DS=0000 ES=0000 FS=0000 GS=0000 SS=0000 TR=e040 (XEN) FSBase=0000000000000000 GSBase=0000000000000000 TRBase=ffff828c802a8a80
(XEN) GDTBase=ffff828c800f3000 IDTBase=ffff828c802ac420
(XEN) CR0=0000000080050033 CR3=000000007cfd4000 CR4=00000000000026f0 (XEN) Sysenter RSP=ffff828c8026ffd0 CS:RIP=e008:ffff828c801c7290 (XEN) Host PAT = 0x0000000000000000
(XEN) *** Control State ***
(XEN) PinBased=0000003f CPUBased=b6a1e7fe SecondaryExec=00000041 (XEN) EntryControls=000011ff ExitControls=0003efff
(XEN) ExceptionBitmap=00044080
(XEN) VMEntry: intr_info=00000000 errcode=00000000 ilen=00000000 (XEN) VMExit: intr_info=00000000 errcode=00008000 ilen=00000000
(XEN) reason=80000021 qualification=00000000
(XEN) IDTVectoring: info=00000000 errcode=00000000
(XEN) TPR Threshold = 0x00
(XEN) EPT pointer = 0x0000000000000000
(XEN) Virtual processor ID = 0x0000
(XEN) **************************************
(XEN) domain_crash called from vmx.c:2218
(XEN) Domain 1 (vcpu#0) crashed on cpu#0:
(XEN) ----[ Xen-3.4.0-rc3-pre x86_64 debug=n Not tainted ]----
(XEN) CPU: 0
(XEN) RIP: 14a2:[<000000000000002a>]
(XEN) RFLAGS: 0000000000023202 CONTEXT: hvm guest

(XEN) rax: 0000000000000007   rbx: 0000000000001490   rcx: 0000000000000000
(XEN) rdx: 0000000000001da8   rsi: 0000000000000000   rdi: 0000000000000000
(XEN) rbp: 0000000000008ebf   rsp: 0000000000000080   r8:  0000000000000000
(XEN) r9:  0000000000000000   r10: 0000000000000000   r11: 0000000000000000
(XEN) r12: 0000000000000000   r13: 0000000000000000   r14: 0000000000000000
(XEN) r15: 0000000000000000   cr0: 0000000080000019   cr4: 0000000000000000
(XEN) cr3: 0000000001443000   cr2: 0000000000000000

(XEN) ds: 1da8 es: 1eae fs: 0000 gs: 0000 ss: 1ea6 cs: 14a2

Any ideas to what is wrong now?

Tom

2009/4/23 Keir Fraser <[email protected]>

Quoted 110 lines

Patch is attached. It is in addition to the LTR/LLDT patch.

-- Keir

Quoted 6 lines · Keir Fraser

A task switch reloads on segment registers, so it is impossible to enter vm86 mode with 'bad' segment state even via a task switch.

If the guest really is trying to enter vm86 mode via a task switch (which would be somewhat bizarre, although a valid thing to do) then hvm_load_segment_selector() needs updating to deal with VM86 mode. I'll

make

Quoted 13 lines

a patch.

-- Keir

Quoted 7 lines · Tom Rotenberg

So, do u have any suggestion, on how can i fix this issue?

2009/4/23 Tim Deegan <[email protected]>

Quoted 4 lines
Quoted 3 lines · Tom Rotenberg

Keir,

After further testing, it seems like the flow of events were like

this:

Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 7 lines

there was a VMEXIT with the reason of task switch, which changed to vm86mode
(!), and upon trying to resume from this vmexit, the cpu raised an exception.

And the question is why and how did the task switch caused the vm86 mode to be turned on? is it even legal?

Yes, task-switching into vm86 mode is legal; ISTR it and IRET are the only ways mentioned in the SDMs of getting into vm86.

Looks like Xen doesn't support it, though. It would need special handling of the segment state to get round the extra restrictions that Intel imposed on VMENTER (which are stricter than the limits on using vm86 mode unvirtualized).

Cheers,

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

Tim.

Quoted 5 lines

Tom

2009/4/23 Keir Fraser <[email protected]<mailto:[email protected]>> All task switches are emulated, so you can add tracing to

hvm_task_switch()

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

to check if a switch has occurred. An alternative is that the guest

did

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

another LTR while not being emulated?

If you want to remember the last VMEXIT, you?ll have to add code to

store

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

state away somewhere to pick up on the next VMENTRY.

-- Keir

On 23/04/2009 15:08, "Tom Rotenberg" <[email protected]<http://[email protected] <

http://gmail.com>

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line

wrote:

About the TR, i have re-checked it, and it seems like the TR value is

still

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

0x58, althoug the LTR operation put 0x50 into it. Since, i looked at

the

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

LTR
code you sent me, and it seems ok, i tend to suspect, that there was

some

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

kind of (hardware) task switch, which changed the TR value without me knowing, is it possible? because otherwise, i can't really explain why

the

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

TR value is different than what was loaded from the LTR operation...

BTW - how can i track what was the previous VMEXIT before this last

VMENTRY

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

which caused the exception? i think, that probably the last VMEXIT

caused

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

the "change" to vm86 mode, and this is waht causes the problem...

Tom

2009/4/23 Keir Fraser <[email protected]<http://[email protected]
<http://eu.citrix.com> >>
On 23/04/2009 12:44, "Tom Rotenberg" <[email protected]<http://[email protected] <

http://gmail.com>

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

wrote:

However, from the VMCS dump, i saw data, which doesn't seem

compatible

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

with
this, as the LDTR sellector is indeed 0, but has attributes and limit different from zero (although it should have been totaly disabled, by

the

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

LLDT, no?).

The 'unused' flag in the attributes word is set (bit 16) so LDTR is

okay.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

And more important, the TR selector is 0x58, although from the LTR,

it was

Quoted 21 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 1 line

supposed to be 0x50, no?

If 0x50 was loaded then the selector should certainly be 0x50.

-- Keir

Quoted 1 line

(of-course it's possible that there were other instructions who

changed it

Quoted 11 lines
Quoted 10 lines
Quoted 9 lines
Quoted 4 lines
Quoted 1 line

back, however, i am wondering if there is a problem here).

--
Tim Deegan <[email protected]>
Principal Software Engineer, Citrix Systems (R&D) Ltd. [Company #02300071, SL9 0DZ, UK.]

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#33 lore raw
Quoted 4 lines · Tom Rotenberg

Keir,

I applied the patch, and it seems it helped a little, however, the domain is still crashing, with the following error:

Ah, the patch had a bug. Try the attached updated version.

-- Keir

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#34 lore raw

Keir,

I have applied the patch, and it looks like now it passed this part. However, now, it hangs, and doesn't show the PointSec pre-boot GUI. I have also seen the following messages in 'xm dmesg':

(XEN) HVM2: Booting from Hard Disk...
(XEN) HVM2: Booting from 0000:7c00
(XEN) multi.c:3351:d2 write to pagetable during event injection:
cr2=0x2234bc, mfn=0x29c23
(XEN) multi.c:3351:d2 write to pagetable during event injection:
cr2=0x1032ff8, mfn=0x28e32
(XEN) multi.c:3351:d2 write to pagetable during event injection:
cr2=0x102fff8, mfn=0x28e2f

Do u have any idea what may cause this problem?

Tom

2009/4/23 Keir Fraser <[email protected]>

Quoted 13 lines · Tom Rotenberg
Quoted 4 lines

Keir,

I applied the patch, and it seems it helped a little, however, the domain

is

Quoted 1 line

still crashing, with the following error:

Ah, the patch had a bug. Try the attached updated version.

-- Keir

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#35 lore raw
Quoted 13 lines · Tom Rotenberg

I have applied the patch, and it looks like now it passed this part. However, now, it hangs, and doesn't show the PointSec pre-boot GUI. I have also seen the following messages in 'xm dmesg':

(XEN) HVM2: Booting from Hard Disk...
(XEN) HVM2: Booting from 0000:7c00
(XEN) multi.c:3351:d2 write to pagetable during event injection: cr2=0x2234bc, mfn=0x29c23
(XEN) multi.c:3351:d2 write to pagetable during event injection:
cr2=0x1032ff8, mfn=0x28e32
(XEN) multi.c:3351:d2 write to pagetable during event injection:
cr2=0x102fff8, mfn=0x28e2f

Quoted 1 line

Do u have any idea what may cause this problem?

Those messages are usually rare and typically indicate that a guest pagetable page has been recycled as a kernel stack page, and is being written to as part of an exception/interrupt delivery. My guess for why you're seeing it is that you've entered some horrible exception loop where the exception handler causes another exception, and this repeats itself. This would cause the stack to overwrite memory (as exception stack frames stack up one on top of the other on top of the other...), taking out pagetable pages as it goes. You'd then hang or crash when enough memory is overwitten that the exception loop gets broken.

Since the root cause of the exceptions happened some time back in execution, this could be a pain to debug. :-) And my theory may not even be correct...

-- Keir

#36 lore raw

wow... that's sucks :(

Well, let me dive into it, and i will update you when i will understand what is causing this issue.

Thanks.

2009/4/23 Keir Fraser <[email protected]>

Quoted 30 lines · Tom Rotenberg
Quoted 2 lines

I have applied the patch, and it looks like now it passed this part.

However,

Quoted 1 line

now, it hangs, and doesn't show the PointSec pre-boot GUI. I have also

seen

Quoted 5 lines

the following messages in 'xm dmesg':

(XEN) HVM2: Booting from Hard Disk...
(XEN) HVM2: Booting from 0000:7c00
(XEN) multi.c:3351:d2 write to pagetable during event injection:

cr2=0x2234bc,

Quoted 7 lines

mfn=0x29c23
(XEN) multi.c:3351:d2 write to pagetable during event injection:
cr2=0x1032ff8, mfn=0x28e32
(XEN) multi.c:3351:d2 write to pagetable during event injection:
cr2=0x102fff8, mfn=0x28e2f

Do u have any idea what may cause this problem?

Those messages are usually rare and typically indicate that a guest pagetable page has been recycled as a kernel stack page, and is being written to as part of an exception/interrupt delivery. My guess for why you're seeing it is that you've entered some horrible exception loop where the exception handler causes another exception, and this repeats itself. This would cause the stack to overwrite memory (as exception stack frames stack up one on top of the other on top of the other...), taking out pagetable pages as it goes. You'd then hang or crash when enough memory is overwitten that the exception loop gets broken.

Quoted 8 lines

Since the root cause of the exceptions happened some time back in execution,
this could be a pain to debug. :-) And my theory may not even be correct...

-- Keir

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#37 lore raw
In reply to Keir Fraser

Keir,

I'm trying to figure out what causes the bug i'm experiencing, and i suspect that the TSS patch you have sent me has bugs. I saw in your patch, that you are setting the attributes of the every user segment (including CS) to be 0xf3, which sets the segment type to Data R/W. Don't you need to set the CS segment type to be Code R/W?

Tom

2009/4/23 Keir Fraser <[email protected]>

Quoted 30 lines · Tom Rotenberg
Quoted 2 lines

I have applied the patch, and it looks like now it passed this part.

However,

Quoted 1 line

now, it hangs, and doesn't show the PointSec pre-boot GUI. I have also

seen

Quoted 5 lines

the following messages in 'xm dmesg':

(XEN) HVM2: Booting from Hard Disk...
(XEN) HVM2: Booting from 0000:7c00
(XEN) multi.c:3351:d2 write to pagetable during event injection:

cr2=0x2234bc,

Quoted 7 lines

mfn=0x29c23
(XEN) multi.c:3351:d2 write to pagetable during event injection:
cr2=0x1032ff8, mfn=0x28e32
(XEN) multi.c:3351:d2 write to pagetable during event injection:
cr2=0x102fff8, mfn=0x28e2f

Do u have any idea what may cause this problem?

Those messages are usually rare and typically indicate that a guest pagetable page has been recycled as a kernel stack page, and is being written to as part of an exception/interrupt delivery. My guess for why you're seeing it is that you've entered some horrible exception loop where the exception handler causes another exception, and this repeats itself. This would cause the stack to overwrite memory (as exception stack frames stack up one on top of the other on top of the other...), taking out pagetable pages as it goes. You'd then hang or crash when enough memory is overwitten that the exception loop gets broken.

Quoted 8 lines

Since the root cause of the exceptions happened some time back in execution,
this could be a pain to debug. :-) And my theory may not even be correct...

-- Keir

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#38 lore raw

Just saw the reason for the 0xf3 attribute in the Intel Spec. Sorry...

2009/4/26 Tom Rotenberg <[email protected]>

Quoted 8 lines

Keir,

I'm trying to figure out what causes the bug i'm experiencing, and i suspect that the TSS patch you have sent me has bugs. I saw in your patch, that you are setting the attributes of the every user segment (including CS) to be 0xf3, which sets the segment type to Data R/W. Don't you need to set the CS segment type to be Code R/W?

Quoted 44 lines

Tom

2009/4/23 Keir Fraser <[email protected]>

Quoted 40 lines · Tom Rotenberg
Quoted 3 lines

I have applied the patch, and it looks like now it passed this part.

However,

Quoted 1 line

now, it hangs, and doesn't show the PointSec pre-boot GUI. I have also

seen

Quoted 5 lines

the following messages in 'xm dmesg':

(XEN) HVM2: Booting from Hard Disk...
(XEN) HVM2: Booting from 0000:7c00
(XEN) multi.c:3351:d2 write to pagetable during event injection:

cr2=0x2234bc,

Quoted 7 lines

mfn=0x29c23
(XEN) multi.c:3351:d2 write to pagetable during event injection:
cr2=0x1032ff8, mfn=0x28e32
(XEN) multi.c:3351:d2 write to pagetable during event injection:
cr2=0x102fff8, mfn=0x28e2f

Do u have any idea what may cause this problem?

Those messages are usually rare and typically indicate that a guest pagetable page has been recycled as a kernel stack page, and is being written to as part of an exception/interrupt delivery. My guess for why you're seeing it is that you've entered some horrible exception loop where the exception handler causes another exception, and this repeats itself. This would cause the stack to overwrite memory (as exception stack frames stack up one on top of the other on top of the other...), taking out pagetable pages as it goes. You'd then hang or crash when enough memory is overwitten that the exception loop gets broken.

Since the root cause of the exceptions happened some time back in execution,
this could be a pain to debug. :-) And my theory may not even be correct...

-- Keir

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#39 lore raw

Keir/Tim

Why did u add the check in load_seg() function x86_emulate.c:
diff -r 8b152638adaa xen/arch/x86/x86_emulate/x86_emulate.c
--- a/xen/arch/x86/x86_emulate/x86_emulate.c Thu Apr 23 16:22:48 2009
+0100
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c Thu Apr 23 18:47:17 2009
+0100
@@ -1099,7 +1099,7 @@

          (ops->write_segment == NULL) )
         return X86EMUL_UNHANDLEABLE;

- if ( in_protmode(ctxt, ops) )
+ if ( in_protmode(ctxt, ops) || !is_x86_user_segment(seg) )

         return protmode_load_seg(seg, sel, ctxt, ops);

Why is it needed? and what will happen in case we will need to emulate a load of user segment in protected mode? right now, it will just not be performed. is this even legal?

Tom

2009/4/26 Tom Rotenberg <[email protected]>

Quoted 59 lines

Just saw the reason for the 0xf3 attribute in the Intel Spec. Sorry...

2009/4/26 Tom Rotenberg <[email protected]>

Keir,

Quoted 53 lines

I'm trying to figure out what causes the bug i'm experiencing, and i suspect that the TSS patch you have sent me has bugs. I saw in your patch, that you are setting the attributes of the every user segment (including CS) to be 0xf3, which sets the segment type to Data R/W. Don't you need to set the CS segment type to be Code R/W?

Tom

2009/4/23 Keir Fraser <[email protected]>

Quoted 42 lines · Tom Rotenberg
Quoted 3 lines

I have applied the patch, and it looks like now it passed this part.

However,

Quoted 1 line

now, it hangs, and doesn't show the PointSec pre-boot GUI. I have also

seen

Quoted 5 lines

the following messages in 'xm dmesg':

(XEN) HVM2: Booting from Hard Disk...
(XEN) HVM2: Booting from 0000:7c00
(XEN) multi.c:3351:d2 write to pagetable during event injection:

cr2=0x2234bc,

Quoted 7 lines

mfn=0x29c23
(XEN) multi.c:3351:d2 write to pagetable during event injection:
cr2=0x1032ff8, mfn=0x28e32
(XEN) multi.c:3351:d2 write to pagetable during event injection:
cr2=0x102fff8, mfn=0x28e2f

Do u have any idea what may cause this problem?

Those messages are usually rare and typically indicate that a guest pagetable page has been recycled as a kernel stack page, and is being written to as part of an exception/interrupt delivery. My guess for why you're seeing it is that you've entered some horrible exception loop where
the exception handler causes another exception, and this repeats itself. This would cause the stack to overwrite memory (as exception stack frames stack up one on top of the other on top of the other...), taking out pagetable pages as it goes. You'd then hang or crash when enough memory is
overwitten that the exception loop gets broken.

Since the root cause of the exceptions happened some time back in execution,
this could be a pain to debug. :-) And my theory may not even be correct...

-- Keir

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#40 lore raw

That chunk actually has no effect right now, as we should never load a non-user segment while in real mode. You could throw that patch chunk away if you like.

-- Keir

Quoted 14 lines · Tom Rotenberg

Keir/Tim

Why did u add the check in load_seg() function x86_emulate.c:
diff -r 8b152638adaa xen/arch/x86/x86_emulate/x86_emulate.c

xen/arch/x86/x86_emulate/x86_emulate.c    Thu Apr 23 18:47:17 2009 +0100 renamed from xen/arch/x86/x86_emulate/x86_emulate.c    Thu Apr 23 16:22:48 2009 +0100 +0 -0
@@ -1099,7 +1099,7 @@
           (ops->write_segment == NULL) )
          return X86EMUL_UNHANDLEABLE;


-    if ( in_protmode(ctxt, ops) )
+    if ( in_protmode(ctxt, ops) || !is_x86_user_segment(seg) ) return protmode_load_seg(seg, sel, ctxt, ops);

Quoted 3 lines

Why is it needed? and what will happen in case we will need to emulate a load of user segment in protected mode? right now, it will just not be performed. is this even legal?

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#41 lore raw

Keir/Tim,

I have a question: i ran into the following code at vmx.c:

    /* Can't inject exceptions in virtual 8086 mode because they would
     * use the protected-mode IDT.  Emulate at the next vmenter instead. */
    if ( curr->arch.hvm_vmx.vmx_realmode )
        curr->arch.hvm_vmx.vmx_emulate = 1;

And i wonder if this has something to do with the problem i 'm experiencing. First, i don't understand this code, since the comment is talking about vm86 mode, while the actual code checks for realmode. Is this ok?

Second, i wonder if there is a problem in updating the current state of the CPU, if it was changed during a task-switch (to vm86 mode), and it wasn't updated in the arch.hvm_vmx.vmx_realmode flag, then this might cause the problem, no?

And last: i found that the last trap/event which is re-happening all the time, and by that trashes all the memory untill the domain crashes, is trap 0x20, which i'm not sure, but i think it's a system call. Do u have any reason to think why trap 0x20, could lead to this problem? maybe there is a bug in the task-switch code which might cause it?

Tom

2009/4/26 Keir Fraser <[email protected]>

Quoted 24 lines

That chunk actually has no effect right now, as we should never load a
non-user segment while in real mode. You could throw that patch chunk away if you like.

-- Keir

On 26/04/2009 12:23, "Tom Rotenberg" <[email protected]> wrote:

Keir/Tim

Why did u add the check in load_seg() function x86_emulate.c:
diff -r 8b152638adaa xen/arch/x86/x86_emulate/x86_emulate.c
--- a/xen/arch/x86/x86_emulate/x86_emulate.c Thu Apr 23 16:22:48 2009
+0100
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c Thu Apr 23 18:47:17 2009
+0100

(quoted diff) +1 -1
@@ -1099,7 +1099,7 @@
          (ops->write_segment == NULL) )
         return X86EMUL_UNHANDLEABLE;
 
-    if ( in_protmode(ctxt, ops) )
+    if ( in_protmode(ctxt, ops) || !is_x86_user_segment(seg) )
         return protmode_load_seg(seg, sel, ctxt, ops);
 
Quoted 5 lines

Why is it needed? and what will happen in case we will need to emulate a load of user segment in protected mode? right now, it will just not be performed. is this even legal?

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#42 lore raw
Quoted 3 lines · Tom Rotenberg

And i wonder if this has something to do with the problem i 'm experiencing. First, i don't understand this code, since the comment is talking about vm86 mode, while the actual code checks for realmode. Is this ok?

Yes, Xen tries to emulate real mode by running the guest in vm86 mode. This is faster than full emulation. You have a guest that really is in vm86 mode (not merely to emulate real mode).

Quoted 4 lines

Second, i wonder if there is a problem in updating the current state of the CPU, if it was changed during a task-switch (to vm86 mode), and it wasn't updated in the arch.hvm_vmx.vmx_realmode flag, then this might cause the problem, no?

No, the guest isn't in real mode, it really is in vm86 mode.

Quoted 4 lines

And last: i found that the last trap/event which is re-happening all the time, and by that trashes all the memory untill the domain crashes, is trap 0x20, which i'm not sure, but i think it's a system call. Do u have any reason to think why trap 0x20, could lead to this problem?

Trap 0x20 is either a hardware interrupt or a software interrupt. Since the meaning of vectors >=0x20 is configured by software, we can't know what vector 0x20 is being used for here. However, often the 8259 PIC is based at vector 0x20, and that might mean that this recurring interrupt is the PIT (programmable interval timer).

Quoted 1 line

maybe there is a bug in the task-switch code which might cause it?

You wish. ;-)

-- Keir